Socket
Socket
Sign inDemoInstall

last-run

Package Overview
Dependencies
0
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    last-run

Capture and retrieve the last time a function was run


Version published
Weekly downloads
1.3M
increased by5.18%
Maintainers
2
Install size
5.88 kB
Created
Weekly downloads
 

Changelog

Source

2.0.0 (2022-01-10)

⚠ BREAKING CHANGES

  • Normalize repository, dropping node <10.13 support (#8)

Features

  • Remove default-resolution dependency since platform has consistent resolution (50a17d8)
  • Support non-extensible functions by removing WeakMap shim (50a17d8)

Miscellaneous Chores

  • Normalize repository, dropping node <10.13 support (#8) (50a17d8)

Readme

Source

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

Keywords

FAQs

Last updated on 10 Jan 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc