GithubHelp home page GithubHelp logo

isabella232 / last-run Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gulpjs/last-run

0.0 0.0 0.0 22 KB

Capture and retrieve the last time a function was run

License: MIT License

JavaScript 100.00%

last-run's Introduction

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

last-run's People

Contributors

erikkemperman avatar github-actions[bot] avatar pdehaan avatar phated avatar sttk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.