gajus / approximate-now Goto Github PK
View Code? Open in Web Editor NEWApproximate (fast) current UNIX time.
License: Other
Approximate (fast) current UNIX time.
License: Other
Is it intentional for the package's API access to differ from that of Date? I initially expected the package to work as a drop-in replacement of Date.now()
by exporting a function by the name of now()
rather than an object with a property by the name of now
.
Is this something you'd allow a PR to change? I have a branch with performance increases adding up to a little over 100%. I'd like to create a PR for it but it's based on an API refactor that would close this issue.
There's an opportunity to optimize a majority of the calculations in the library. Namely, the assignments to maxNow
:
approximate-now/src/approximateNow.ts
Line 2 in 6ea8bab
let now = 50 * Math.ceil((now + 50) / 50);
let maxNow = now + 50;
t0 := scale × ceil( x0 ∕ scale )
where x0 is t
t1 := scale × ceil( x1 ∕ scale )
where x1 is t0 + scale
Using the definition of t0:
t1 = scale × ceil( x0 ∕ scale ) + scale
t1 = t0 + scale
There isn't a lock file in this repository. It appears that you don't typically use them in any of your projects. Is there a particular reason for that? I didn't want to commit a lock file without knowing first.
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.