Comparing version 1.0.1 to 2.0.0
@@ -1,96 +0,43 @@ | ||
"use strict"; | ||
'use strict' | ||
var _createClass = require("babel-runtime/helpers/create-class")["default"]; | ||
class Delayer { | ||
var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"]; | ||
constructor(delay) { | ||
this.delay = delay | ||
var _Promise = require("babel-runtime/core-js/promise")["default"]; | ||
this.promise = new Promise((resolve, reject) => { | ||
let timeoutID = setTimeout(() => { | ||
resolve() | ||
}, delay) | ||
var _regeneratorRuntime = require("babel-runtime/regenerator")["default"]; | ||
this.cancel = () => { | ||
clearTimeout(timeoutID) | ||
let err = new Error("Delayer cancelled.") | ||
err.setByDelayer = Delayer | ||
reject(err) | ||
} | ||
}) | ||
} | ||
var Delayer = (function () { | ||
function Delayer(delay) { | ||
var _this = this; | ||
} | ||
_classCallCheck(this, Delayer); | ||
this.delay = delay; | ||
this.promise = new _Promise(function (resolve, reject) { | ||
var timeoutID = setTimeout(function () { | ||
resolve(); | ||
}, delay); | ||
_this.cancel = function () { | ||
clearTimeout(timeoutID); | ||
var err = new Error("Delayer cancelled."); | ||
err.setByDelayer = Delayer; | ||
reject(err); | ||
}; | ||
}); | ||
Delayer.cli = async function(argv) { | ||
try { | ||
let args = argv.slice(2) | ||
if (args.length === 0) return | ||
let delay = parseInt(args[0]) | ||
if (delay < 0) return | ||
let d = new Delayer(delay) | ||
await d.promise | ||
} | ||
catch (err) { | ||
console.error(err) | ||
process.exit(1) | ||
} | ||
} | ||
_createClass(Delayer, null, [{ | ||
key: "console", | ||
value: (function (_console) { | ||
function console() { | ||
return _console.apply(this, arguments); | ||
} | ||
console.toString = function () { | ||
return _console.toString(); | ||
}; | ||
return console; | ||
})(function callee$1$0() { | ||
var args, delay, d; | ||
return _regeneratorRuntime.async(function callee$1$0$(context$2$0) { | ||
while (1) switch (context$2$0.prev = context$2$0.next) { | ||
case 0: | ||
console.log(1); | ||
args = process.argv.slice(2); | ||
if (!(args.length === 0)) { | ||
context$2$0.next = 4; | ||
break; | ||
} | ||
return context$2$0.abrupt("return"); | ||
case 4: | ||
delay = parseInt(args[0]); | ||
if (!(delay < 0)) { | ||
context$2$0.next = 7; | ||
break; | ||
} | ||
return context$2$0.abrupt("return"); | ||
case 7: | ||
d = new Delayer(delay); | ||
console.log(2); | ||
context$2$0.next = 11; | ||
return _regeneratorRuntime.awrap(d.promise); | ||
case 11: | ||
console.log(3); | ||
case 12: | ||
case "end": | ||
return context$2$0.stop(); | ||
} | ||
}, null, this); | ||
}) | ||
}]); | ||
return Delayer; | ||
})(); | ||
if (require.main === module) { | ||
Delayer.console(); | ||
Delayer.cli() | ||
} | ||
module.exports = Delayer; | ||
//# sourceMappingURL=delayer.js.map | ||
module.exports = Delayer |
{ | ||
"name": "delayer", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Create a cancellable promise that will be resolved in a specified amount of time.", | ||
"main": "lib/delayer.js", | ||
"main": "dist/delayer.js", | ||
"bin": { | ||
@@ -11,6 +11,7 @@ "delayer": "./bin/delayer" | ||
"start": "node .", | ||
"pretest": "npm run mocha", | ||
"test": "mocha", | ||
"compile": "babel src --stage 1 --out-dir lib --source-maps --optional runtime", | ||
"watch": "babel src --stage 1 --out-dir lib --source-maps --optional runtime --watch" | ||
"pretest": "npm run compile", | ||
"test": "ava", | ||
"compile": "babel lib --out-dir dist", | ||
"watch": "npm run compile -- --watch", | ||
"prepublish": "npm run compile" | ||
}, | ||
@@ -34,10 +35,15 @@ "repository": { | ||
"devDependencies": { | ||
"babel": "^5.8.5", | ||
"chai": "^3.2.0", | ||
"chai-as-promised": "^5.1.0", | ||
"mocha": "^2.2.5" | ||
"ava": "^0.12.0", | ||
"babel-cli": "^6.5.1", | ||
"babel-plugin-transform-async-to-generator": "^6.5.0" | ||
}, | ||
"dependencies": { | ||
"babel-runtime": "^5.8.5" | ||
"babel": { | ||
"plugins": [ | ||
"transform-async-to-generator" | ||
], | ||
"sourceMaps": true | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
} | ||
} |
@@ -5,10 +5,15 @@ # delayer | ||
[![npm](https://img.shields.io/npm/v/delayer.svg?style=flat-square)](https://www.npmjs.com/package/delayer) | ||
[![Build Status](https://img.shields.io/travis/seangenabe/delayer/master.svg?style=flat-square)](https://travis-ci.org/seangenabe/delayer) | ||
[![devDependency Status](https://img.shields.io/david/dev/seangenabe/delayer.svg?style=flat-square)](https://david-dm.org/seangenabe/delayer#info=devDependencies) | ||
[![node](https://img.shields.io/node/v/delayer.svg?style=flat-square)](https://nodejs.org/en/download/) | ||
## Usage | ||
### API | ||
var Delayer = require('delayer') | ||
const Delayer = require('delayer') | ||
#### Constructor | ||
var d = new Delayer(delay) | ||
let d = new Delayer(delay) | ||
@@ -29,6 +34,2 @@ * `delay`: The amount of time to delay, in milliseconds. | ||
#### `Delayer.console()` | ||
Invokes the CLI. | ||
### CLI | ||
@@ -35,0 +36,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
3
10
116
40
6740
1
- Removedbabel-runtime@^5.8.5
- Removedbabel-runtime@5.8.38(transitive)
- Removedcore-js@1.2.7(transitive)