Capture and retrieve the last time a function was run
Last updated 5 years ago by phated .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install last-run 
SYNC missed versions from official npm registry.


NPM version Downloads Build Status AppVeyor Build Status Coveralls Status Gitter chat

Capture and retrieve the last time a function was run.


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

function myFunc(){}

// capture the run after (or before) calling the function

// retrieve the last run time
//-> outputs the when capture was called


Note: this module uses a WeakMap shim, and throws on non-extensible functions on platforms that don't have a native WeakMap implementation

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 node v0.10 or with file system like HFS or FAT, fs.stat time attributes like mtime precision is one second.

Assuming lastRun(fn) returns 1426000001111, lastRun(fn, 1000) returns 1426000001000.

The default time resolution is 1000 on node v0.10, 0 on node 0.11+ and iojs. More information at default-resolution and undertaker PR #17.

lastRun.capture(fn, [timestamp])

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


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



Current Tags

  • 1.1.1                                ...           latest (5 years ago)

6 Versions

  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (2)
Today 198
This Week 198
This Month 34,008
Last Day 621
Last Week 10,711
Last Month 51,688
Dependencies (2)
Dev Dependencies (8)

Copyright 2014 - 2017 © |