JSPM

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

Capture and retrieve the last time a function was run

Package Exports

  • last-run
  • last-run/index.js

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 (last-run) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

last-run

NPM version Downloads Build Status Coveralls Status

Capture and retrieve the last time a function was run.

Usage

var lastRun = require('last-run');

function myFunc() {}

myFunc();
// capture the run after (or before) calling the function
lastRun.capture(myFunc);

// retrieve the last run time
lastRun(myFunc);
//-> outputs the Date.now() when capture was called

API

lastRun(fn, [timeResolution]) => [Timestamp]

Takes a function (fn) and returns a timestamp of the last time the function was captured.

Returns undefined if the function has not been captured.

The timestamp is always given in millisecond but the time resolution can be reduced (rounded down). The use case is to be able to compare a build time to a file time attribute. On some file systems, fs.stat time attributes like mtime might have one second precision.

lastRun.capture(fn, [timestamp])

Takes a function (fn) and captures the current timestamp with Date.now(). If passed the optional timestamp, captures that time instead of Date.now(). The captured timestamp can then be retrieved using the lastRun function.

lastRun.release(fn)

Takes a function (fn) and removes the last run timestamp for it.

License

MIT