taijinlee / humanize Goto Github PK
View Code? Open in Web Editor NEWThis project forked from milanvrekic/js-humanize
A JS library for adding a “human touch” to data.
License: MIT License
This project forked from milanvrekic/js-humanize
A JS library for adding a “human touch” to data.
License: MIT License
the calculation is done properly, but still very brittle. Make this more robust. Reference RoR's relative time to now to do it properly
It would be really nice to have the ability to just pull in the methods you need, instead of pulling in the entire library for a single method. I have a situation where I only need the numberFormat
section, which is 10 lines of code, but to get at it, I need to pull in the entire library, adding unnecessary bloat. These days, when building mobile apps, every byte counts.
As suggested in issue #19, it would be really cool to have the abilty to choose the individual method you want via the destructing syntax:
import { date } from 'humanize';
or you can go the same route as lodash, with individual module exports, so that you can require them in by name:
import date from 'humanize/date';
`humanize = require("humanize")
console.log( humanize.naturalDay(new Date(),"m-d-Y" ) )
// returns "07-08-2016"`
Doesn't work on my application or tonicDec/npm
Current tests.html is wrong because of the modifications
I am using this module client side and don't want to ship the entire humanize package. Is there a way to require just the date
method? Something like this:
import { date } from "humanize";
Just curious!
https://github.com/taijinlee/humanize/blob/master/humanize.js
line 405:
units = units || ['', 'K', 'M', 'B', 'T'],
This should be ['', 'K', 'M', 'G', 'T'],
There's no information about the license in package.json file
Write in new stuff
It seems like we should have a 0.0.8 tag, since the version has been bumped.
Right now humanize.relativeTime
reports decimal seconds for recent events. Adding Math.floor(timediff)
when less than 60 seconds should fix it.
Right now I return actual strings. instead, I should pass back keys so anybody can use it the way they'd like (and helps with internationalization when needed)
Imagine I have 2 disks, one 1TB and one 4TB, both 81% full.
With 0DP, the first will be represented with 5 characters, with decent precision :810GB
but the 4TB HDD used space would be represented with 3: 3TB
which is not accurate enough (only 4 possible levels). I could add 1 or 2 decimal places, but then that would make the former unnecessarily long: 810.00GB
. This isn't good for typography and space usage.
I think the solution would be min-significant-figures (MSF): the former would get 810GB and the latter, 43.24GB with a value of 2.
Do you agree?
Thanks for the library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.