Initial import with skill sheet working
This commit is contained in:
42
node_modules/last-run/index.js
generated
vendored
Normal file
42
node_modules/last-run/index.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
var assert = require('assert');
|
||||
|
||||
var runtimes = new WeakMap();
|
||||
|
||||
function isFunction(fn) {
|
||||
return typeof fn === 'function';
|
||||
}
|
||||
|
||||
function lastRun(fn, timeResolution) {
|
||||
assert(isFunction(fn), 'Only functions can check lastRun');
|
||||
|
||||
var time = runtimes.get(fn);
|
||||
|
||||
if (time == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var resolution = parseInt(timeResolution, 10) || 1;
|
||||
|
||||
return time - (time % resolution);
|
||||
}
|
||||
|
||||
function capture(fn, timestamp) {
|
||||
assert(isFunction(fn), 'Only functions can be captured');
|
||||
|
||||
timestamp = timestamp || Date.now();
|
||||
|
||||
runtimes.set(fn, timestamp);
|
||||
}
|
||||
|
||||
function release(fn) {
|
||||
assert(isFunction(fn), 'Only functions can be captured');
|
||||
|
||||
runtimes.delete(fn);
|
||||
}
|
||||
|
||||
lastRun.capture = capture;
|
||||
lastRun.release = release;
|
||||
|
||||
module.exports = lastRun;
|
||||
Reference in New Issue
Block a user