JSPM

now-immediate

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7
  • Score
    100M100P100Q37682F
  • License MIT

Package Exports

  • now-immediate

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (now-immediate) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

##now-immediate

Package provide function, that returns timestamp in ms (like Date.now()).

But after 1st usage, on this event loop, function will return 1st answer.

Example:

var nowIm = require('now-immediate');
console.log('Start');
console.log('Date.now(): '+Date.now()+'\tnowIm(): '+nowIm());
for(var i = 0; i < 10000000; i++){
  /123/.test(i);
}
console.log('Finish');
console.log('Date.now(): '+Date.now()+'\tnowIm(): '+nowIm());
setImmediate(function(){
  console.log('Next loop');
  console.log('Date.now(): '+Date.now()+'\tnowIm(): '+nowIm());
});

The result will be:

Start
Date.now(): 1460683017773       nowIm(): 1460683017773
Finish
Date.now(): 1460683019252       nowIm(): 1460683017773
Next loop
Date.now(): 1460683019254       nowIm(): 1460683019254

In some case, you may need this behaviour. Also it X16+ just faster, than Date.now().