New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

last-run

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

last-run

Capture and retrieve the last time a function was run

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

last-run

Travis Build 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

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 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

Keywords

FAQs

Package last updated on 12 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc