HubSpot/humanize là dự án mã nguồn mở trên GitHub, viết chủ yếu bằng JavaScript, với 919 sao. A simple utility library for making the web more humane. #hubspot-open-source
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
Humanize.intword(123456789, 'nopnopnopnop', 1)
// "123.5M"
Humanize.intword(123456789, 'this is a nop', 3)
// "123.457M"
Humanize.intword(10, 'still a nop', 1)
// "10"
compactInteger
Converts an integer into its most compact representation. Decimal precision is ignored for all integers, n, such that abs(n) < 1000.
Humanize.compactInteger(123456789, 1)
// "123.5M"
// Switch to scientific notation for trillons, because no one knows those abbreviations.
Humanize.compactInteger(-7832186132456328967, 4)
// "-7.8322x10^18"
Humanize.compactInteger(-100, 2)
// "-100"
boundedNumber
Bounds a value from above. Modified values have customizable ending strings ('+' by default)
truncatenumber - DEPRECATED - This method will not be present in the next major version.
Alias for boundedNumber
ordinal
Converts an integer to its ordinal as a string.
Humanize.ordinal(22)
// "22nd"
times
Interprets numbers as occurences. Also accepts an optional array/map of overrides.
for (i=0; i<5; i++) {
Humanize.times(i, {"4": "too many"});
// Bonus!
if (i === 1) {
Humanize.times(1.1);
}
}
// never
// once
// 1.1 times
// twice
// 3 times
// too many times
pace
Matches a pace (value and interval) with a logical time frame. Very useful for slow paces.
second = 1000
week = 6.048e8
decade = 3.156e11
Humanize.pace(1.5, second, "heartbeat")
// Approximately 2 heartbeats per second
Humanize.pace(4, week)
// Approximately 4 times per week
Humanize.pace(1, decade, "life crisis")
// Less than 1 life crisis per week
fileSize
Formats the value like a 'human-readable' file size (i.e. '13 KB', '4.1 MB', '102 bytes', etc).
Truncates a string if it is longer than the specified number of characters. Truncated strings will end with a translatable ellipsis sequence ("…").
Humanize.truncate('long text is good for you')
// "long text is good for you"
Humanize.truncate('long text is good for you', 19)
// "long text is goo..."
Humanize.truncate('long text is good for you', 19, '... etc')
// "long text is... etc"
truncateWords
Truncates a string after a certain number of words.
Humanize.truncateWords('long text is good for you', 5)
// "long text is good for ..."
truncatewords - DEPRECATED - This method will not be present in the next major version.
Alias for truncateWords
nl2br and br2nl
Flexible conversion of <br/> tags to newlines and vice versa.
// Use your imagination
capitalize
Capitalizes the first letter in a string, optionally downcasing the tail.
Intelligently capitalizes eligible words in a string and normalizes internal whitespace.
Humanize.titleCase("some of a boring string")
// "Some of a Boring String"
Humanize.titleCase("cool the iTunes cake, O'Malley!")
// "Cool the iTunes Cake, O'Malley!"
titlecase - DEPRECATED - This method will not be present in the next major version.
Alias for titleCase
Arrays
oxford
Converts a list of items to a human readable string with an optional limit.
items = ['apple', 'orange', 'banana', 'pear', 'pineapple']
Humanize.oxford(items)
// "apple, orange, banana, pear, and pineapple"
Humanize.oxford(items, 3)
// "apple, orange, banana, and 2 others"
// Pluralizes properly too!
Humanize.oxford(items, 4)
// "apple, orange, banana, pear, and 1 other"
Humanize.oxford(items, 3, "and some other fruits")
// "apple, orange, banana, and some other fruits"
frequency
Describes how many times an item appears in a list
catPics = [
'https://media2.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif',
'https://media3.giphy.com/media/uzglgIsyY1Cgg/giphy.gif'
]
dogPics = []
"Cats " + Humanize.frequency(catPics, "typed on keyboards")
// "Cats typed on keyboards 3 times"
"Dogs " + Humanize.frequency(docPics, "typed on keyboards")
// "Dogs never typed on keyboards"
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/HubSpot/humanize là nguồn chính thức.
HubSpot/humanize có bao nhiêu sao?
HubSpot/humanize có 919 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/HubSpot/humanize. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
HubSpot/humanize có phải mã nguồn mở không?
Có — HubSpot/humanize phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/HubSpot/humanize.
HubSpot/humanize có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho HubSpot/humanize. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
HubSpot/humanize có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho HubSpot/humanize. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
HubSpot/humanize còn đang phát triển không?
Commit gần nhất trên HubSpot/humanize là 2.8 năm trước (theo timestamp GitHub). Repo có 72 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
humanize có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về humanize.