| Server IP : 82.208.35.60 / Your IP : 216.73.216.238 Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31 System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64 User : studiokobylisy_cz ( 1008) PHP Version : 7.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/studiokobylisy_cz/www/wp-content/themes/studiokobylisy/node_modules/last-run/ |
Upload File : |
'use strict';
var assert = require('assert');
var WM = require('es6-weak-map');
var hasNativeWeakMap = require('es6-weak-map/is-native-implemented');
var defaultResolution = require('default-resolution');
var runtimes = new WM();
function isFunction(fn) {
return (typeof fn === 'function');
}
function isExtensible(fn) {
if (hasNativeWeakMap) {
// Native weakmap doesn't care about extensible
return true;
}
return Object.isExtensible(fn);
}
function lastRun(fn, timeResolution) {
assert(isFunction(fn), 'Only functions can check lastRun');
assert(isExtensible(fn), 'Only extensible functions can check lastRun');
var time = runtimes.get(fn);
if (time == null) {
return;
}
var resolution = defaultResolution(timeResolution);
return time - (time % resolution);
}
function capture(fn, timestamp) {
assert(isFunction(fn), 'Only functions can be captured');
assert(isExtensible(fn), 'Only extensible functions can be captured');
timestamp = timestamp || Date.now();
runtimes.set(fn, timestamp);
}
function release(fn) {
assert(isFunction(fn), 'Only functions can be captured');
assert(isExtensible(fn), 'Only extensible functions can be captured');
runtimes.delete(fn);
}
lastRun.capture = capture;
lastRun.release = release;
module.exports = lastRun;