On GitHub, HubSpot/humanize has picked up 919 stars, JavaScript. A simple utility library for making the web more humane. #hubspot-open-source
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
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"
No homepage URL was recorded for HubSpot/humanize in TopGit's last sync. The README tab above frequently contains screenshots and demo links, or check the repository description on GitHub.
Does HubSpot/humanize have any tags?
TopGit's last sync did not record any GitHub topics for HubSpot/humanize. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on HubSpot/humanize?
The most recent commit recorded on HubSpot/humanize was 2.8 years ago, based on the GitHub push timestamp. The repository has 72 forks — one of the better signals of community interest.
How many stars does HubSpot/humanize have?
HubSpot/humanize has 919 GitHub stars — refresh the page for the live number, or check github.com/HubSpot/humanize. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is HubSpot/humanize open source?
Yes — HubSpot/humanize ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/HubSpot/humanize.
Where do I read more about HubSpot/humanize?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/HubSpot/humanize is the definitive source.
Read full README in the tab above.
Want a second opinion on humanize?
Ask an AI that can read this page — one click and you get its take on humanize.