node-gulp-4.0.2+~cs38.20.35/000077500000000000000000000000001415667007300150405ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/.editorconfig000066400000000000000000000003051415667007300175130ustar00rootroot00000000000000# http://editorconfig.org root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false node-gulp-4.0.2+~cs38.20.35/.eslintrc000066400000000000000000000000301415667007300166550ustar00rootroot00000000000000{ "extends": "gulp" } node-gulp-4.0.2+~cs38.20.35/.jscsrc000066400000000000000000000000271415667007300163270ustar00rootroot00000000000000{ "preset": "gulp" } node-gulp-4.0.2+~cs38.20.35/.travis.yml000066400000000000000000000001711415667007300171500ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '5' - '4' - '0.12' - '0.10' after_script: - npm run coveralls node-gulp-4.0.2+~cs38.20.35/LICENSE000066400000000000000000000021421415667007300160440ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2015 Blaine Bublitz, Eric Schoffstall and other contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. node-gulp-4.0.2+~cs38.20.35/README.md000066400000000000000000000055561415667007300163320ustar00rootroot00000000000000

# last-run [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] Capture and retrieve the last time a function was run. ## Usage ```js 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`][default-resolution] and [undertaker PR #17][undertaker-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 [default-resolution]: https://github.com/gulpjs/default-resolution [undertaker-17]: https://github.com/gulpjs/undertaker/pull/17#issuecomment-82374512 [downloads-image]: http://img.shields.io/npm/dm/last-run.svg [npm-url]: https://www.npmjs.com/package/last-run [npm-image]: http://img.shields.io/npm/v/last-run.svg [travis-url]: https://travis-ci.org/gulpjs/last-run [travis-image]: http://img.shields.io/travis/gulpjs/last-run.svg?label=travis-ci [appveyor-url]: https://ci.appveyor.com/project/gulpjs/last-run [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/last-run.svg?label=appveyor [coveralls-url]: https://coveralls.io/r/gulpjs/last-run [coveralls-image]: http://img.shields.io/coveralls/gulpjs/last-run/master.svg [gitter-url]: https://gitter.im/gulpjs/gulp [gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg node-gulp-4.0.2+~cs38.20.35/appveyor.yml000066400000000000000000000007211415667007300174300ustar00rootroot00000000000000# http://www.appveyor.com/docs/appveyor-yml # http://www.appveyor.com/docs/lang/nodejs-iojs environment: matrix: # node.js - nodejs_version: "0.10" - nodejs_version: "0.12" - nodejs_version: "4" - nodejs_version: "5" - nodejs_version: "6" install: - ps: Install-Product node $env:nodejs_version - npm install test_script: - node --version - npm --version - cmd: npm test build: off # build version format version: "{build}" node-gulp-4.0.2+~cs38.20.35/index.js000066400000000000000000000024421415667007300165070ustar00rootroot00000000000000'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; node-gulp-4.0.2+~cs38.20.35/package.json000066400000000000000000000021061415667007300173250ustar00rootroot00000000000000{ "name": "last-run", "version": "1.1.1", "description": "Capture and retrieve the last time a function was run", "author": "Gulp Team (http://gulpjs.com/)", "contributors": [ "Blaine Bublitz " ], "repository": "gulpjs/last-run", "license": "MIT", "engines": { "node": ">= 0.10" }, "main": "index.js", "files": [ "LICENSE", "index.js" ], "scripts": { "lint": "eslint . && jscs index.js test/", "pretest": "npm run lint", "test": "mocha --async-only", "cover": "istanbul cover _mocha --report lcovonly", "coveralls": "npm run cover && istanbul-coveralls" }, "dependencies": { "default-resolution": "^2.0.0", "es6-weak-map": "^2.0.1" }, "devDependencies": { "eslint": "^1.7.3", "eslint-config-gulp": "^2.0.0", "expect": "^1.19.0", "istanbul": "^0.4.3", "istanbul-coveralls": "^1.0.3", "jscs": "^2.3.5", "jscs-preset-gulp": "^1.0.0", "mocha": "^2.4.5" }, "keywords": [ "execution", "function", "last run", "timing" ] } node-gulp-4.0.2+~cs38.20.35/test/000077500000000000000000000000001415667007300160175ustar00rootroot00000000000000node-gulp-4.0.2+~cs38.20.35/test/.eslintrc000066400000000000000000000000351415667007300176410ustar00rootroot00000000000000{ "extends": "gulp/test" } node-gulp-4.0.2+~cs38.20.35/test/last-run.js000066400000000000000000000074721415667007300201340ustar00rootroot00000000000000'use strict'; var expect = require('expect'); var defaultResolution = require('default-resolution'); var lastRun = require('../'); describe('lastRun', function() { var since; beforeEach(function(done) { since = Date.now(); // Account for default resolution since = since - (since % defaultResolution()); done(); }); it('should record function capture time', function(done) { function test() {} lastRun.capture(test); expect(lastRun(test)).toExist(); expect(lastRun(test)).toBeLessThanOrEqualTo(Date.now()); done(); }); it('should accept a timestamp', function(done) { function test() {} lastRun.capture(test, since); expect(lastRun(test)).toExist(); expect(lastRun(test)).toEqual(since); done(); }); it('removes last run time with release method', function(done) { function test() {} lastRun.capture(test); expect(lastRun(test)).toExist(); lastRun.release(test); expect(lastRun(test)).toNotExist(); done(); }); it('does not error on release if not captures', function(done) { function test() {} lastRun.release(test); expect(lastRun(test)).toNotExist(); done(); }); it('should return undefined for a function not captured', function(done) { function test() {} expect(lastRun(test)).toNotExist(); done(); }); it('should throw on non-functions', function(done) { function obj() { lastRun({}); } function str() { lastRun('wat'); } function num() { lastRun(1); } function undef() { lastRun(undefined); } function nul() { lastRun(null); } expect(obj).toThrow('Only functions can check lastRun'); expect(str).toThrow('Only functions can check lastRun'); expect(num).toThrow('Only functions can check lastRun'); expect(undef).toThrow('Only functions can check lastRun'); expect(nul).toThrow('Only functions can check lastRun'); done(); }); it('works with anonymous functions', function(done) { var test = function() {}; lastRun.capture(test); expect(lastRun(test)).toExist(); expect(lastRun(test)).toBeLessThanOrEqualTo(Date.now()); done(); }); it('should give time with 1s resolution', function(done) { var resolution = 1000; // 1s since = Date.now(); since = since - (since % resolution); function test() {} lastRun.capture(test); expect(lastRun(test, resolution)).toEqual(since); done(); }); it('should accept a string for resolution', function(done) { var resolution = '1000'; // 1s since = Date.now(); since = since - (since % 1000); function test() {} lastRun.capture(test); expect(lastRun(test, resolution)).toEqual(since); done(); }); it('should use default resolution when forced to 0ms resolution', function(done) { var resolution = 0; function test() {} lastRun.capture(test); expect(lastRun(test, resolution)).toEqual(since); done(); }); it('throws on non-enumerable functions when using weakmap shim', function(done) { function extensions() { var test = function() {}; Object.preventExtensions(test); lastRun.capture(test); } function seal() { var test = function() {}; Object.seal(test); lastRun.capture(test); } function freeze() { var test = function() {}; Object.freeze(test); lastRun.capture(test); } if (/v0.10/.test(process.version)) { expect(extensions).toThrow('Only extensible functions can be captured'); expect(seal).toThrow('Only extensible functions can be captured'); expect(freeze).toThrow('Only extensible functions can be captured'); } else { expect(extensions).toNotThrow(); expect(seal).toNotThrow(); expect(freeze).toNotThrow(); } done(); }); });