UNPKG

pnpm

Version:

Fast, disk space efficient package manager

128 lines (127 loc) β€’ 7.75 kB
{ "_args": [ [ { "raw": "delay@4.2.0", "scope": null, "escapedName": "delay", "name": "delay", "rawSpec": "4.2.0", "spec": "4.2.0", "type": "version" }, "/home/zoltan/src/pnpm/pnpm/packages/pnpm" ] ], "_from": "delay@4.2.0", "_hasShrinkwrap": false, "_id": "delay@4.2.0", "_location": "/delay", "_nodeVersion": "8.15.0", "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/delay_4.2.0_1554721298791_0.7755370555598469" }, "_npmUser": { "name": "sindresorhus", "email": "sindresorhus@gmail.com" }, "_npmVersion": "6.9.0", "_phantomChildren": {}, "_requested": { "raw": "delay@4.2.0", "scope": null, "escapedName": "delay", "name": "delay", "rawSpec": "4.2.0", "spec": "4.2.0", "type": "version" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/delay/-/delay-4.2.0.tgz", "_shasum": "3f6c39dbd28aef50355e670fecee050ef01242ce", "_shrinkwrap": null, "_spec": "delay@4.2.0", "_where": "/home/zoltan/src/pnpm/pnpm/packages/pnpm", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "bugs": { "url": "https://github.com/sindresorhus/delay/issues" }, "dependencies": {}, "description": "Delay a promise a specified amount of time", "devDependencies": { "abort-controller": "^3.0.0", "ava": "1.4.1", "currently-unhandled": "^0.4.1", "in-range": "^1.0.0", "time-span": "^3.0.0", "tsd": "^0.7.1", "xo": "^0.24.0" }, "directories": {}, "dist": { "integrity": "sha512-EBX+pZE4qSowGAMr6M0cLiPRQu2Kus/qTNLO7c+EoXpTPJH9ApFdHX+cQU1WsSHXgwhLyidfZ5Hxuq6ctWhSdw==", "shasum": "3f6c39dbd28aef50355e670fecee050ef01242ce", "tarball": "https://registry.npmjs.org/delay/-/delay-4.2.0.tgz", "fileCount": 5, "unpackedSize": 9247, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcqyoUCRA9TVsSAnZWagAAPs4P+gJAZFriwEqlM0oF1jAZ\nhR3Sm2shyXmxQAhS5ZibtQLaANoKtltI3DuAxe1KfQ5k8AL8F+hxEyl2cedq\ndP/85Q5ZgI4eHPe1iE9luHXomHaHhfSpfxq/cGgoNGqBgubYde3c8s3ai3A9\nGi3rHkMaiiE/jAVrM4ZsyMhP3JRue56sfaa/GL04p1c4nu4sa7srzjv12iYX\nWPPvbc+2iDPr6BKvpzNOQ9lbEjnBEQjH8LziqD/SrM6XTJEmFUdeUJB06vg/\nhC5fCM8CNTKcfUdytWy0aCqkacPUe8OfyX8E+VjpeV6K6/IJePF7MwRHXfCd\n6VAp3Nx3C+cvSC3gWVkwOH3MGTO6NG7DTz2h2IZw9jXR4XAppwz3yqZi/Ebq\ngsDWkcjiDMZn84bvEXejtC8xdmeJoH63nzJS69rhJ6Nr3qGmZyKRCD6FPHaj\n5NHPrIMWZvPSuzNODKpuNc4xwMB7Kq5HEQOm1N6ad1VVnkIL60cn+vOzMROM\nL3Q7KAto6yf+OOSpVUE0I+p4us6Pu2gNPVojUMj/ejUNdXmGbtqcnoNjEHLf\n2sk2FAXwPcDXH29ovhl+wydO9XhPES/T+97ajjOma1eJ2rHsvDpYBOXnWB0z\n85LvObL58TB5ovnx5tlOasr73dVgnYuSRlgY6JarVELIrusZbIXMjsiTJjVV\n+Ov9\r\n=I22L\r\n-----END PGP SIGNATURE-----\r\n" }, "engines": { "node": ">=6" }, "files": [ "index.js", "index.d.ts" ], "gitHead": "37c832b90de887c89dddb833b85d093acc90d649", "homepage": "https://github.com/sindresorhus/delay#readme", "keywords": [ "promise", "resolve", "delay", "defer", "wait", "stall", "timeout", "settimeout", "event", "loop", "next", "tick", "delay", "async", "await", "promises", "bluebird" ], "license": "MIT", "maintainers": [ { "name": "jamestalmage", "email": "james@talmage.io" }, { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], "name": "delay", "optionalDependencies": {}, "readme": "# delay [![Build Status](https://travis-ci.org/sindresorhus/delay.svg?branch=master)](https://travis-ci.org/sindresorhus/delay)\n\n> Delay a promise a specified amount of time\n\n\n## Install\n\n```\n$ npm install delay\n```\n\n\n## Usage\n\n```js\nconst delay = require('delay');\n\n(async () => {\n\tbar();\n\n\tawait delay(100);\n\n\t// Executed 100 milliseconds later\n\tbaz();\n})();\n```\n\n\n## API\n\n### delay(milliseconds, [options])\n\nCreate a promise which resolves after the specified `milliseconds`.\n\n### delay.reject(milliseconds, [options])\n\nCreate a promise which rejects after the specified `milliseconds`.\n\n#### milliseconds\n\nType: `number`\n\nMilliseconds to delay the promise.\n\n#### options\n\nType: `Object`\n\n##### value\n\nType: `any`\n\nOptional value to resolve or reject in the returned promise.\n\n##### signal\n\nType: [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)\n\nThe returned promise will be rejected with an AbortError if the signal is aborted. AbortSignal is available in all modern browsers and there is a [ponyfill for Node.js](https://github.com/mysticatea/abort-controller).\n\n### delayPromise.clear()\n\nClears the delay and settles the promise.\n\n### delay.createWithTimers({clearTimeout, setTimeout})\n\nCreates a new `delay` instance using the provided functions for clearing and setting timeouts. Useful if you're about to stub timers globally, but you still want to use `delay` to manage your tests.\n\n## Advanced usage\n\nPassing a value:\n\n```js\nconst delay = require('delay');\n\n(async() => {\n\tconst result = await delay(100, {value: 'πŸ¦„'});\n\n\t// Executed after 100 milliseconds\n\tconsole.log(result);\n\t//=> 'πŸ¦„'\n})();\n```\n\nUsing `delay.reject()`, which optionally accepts a value and rejects it `ms` later:\n\n```js\nconst delay = require('delay');\n\n(async () => {\n\ttry {\n\t\tawait delay.reject(100, {value: new Error('πŸ¦„')});\n\n\t\tconsole.log('This is never executed');\n\t} catch (error) {\n\t\t// 100 milliseconds later\n\t\tconsole.log(error);\n\t\t//=> [Error: πŸ¦„]\n\t}\n})();\n```\n\nYou can settle the delay early by calling `.clear()`:\n\n```js\nconst delay = require('delay');\n\n(async () => {\n\tconst delayedPromise = delay(1000, {value: 'Done'});\n\n\tsetTimeout(() => {\n\t\tdelayedPromise.clear();\n\t}, 500);\n\n\t// 500 milliseconds later\n\tconsole.log(await delayedPromise);\n\t//=> 'Done'\n})();\n```\n\nYou can abort the delay with an AbortSignal:\n\n```js\nconst delay = require('delay');\n\n(async () => {\n\tconst abortController = new AbortController();\n\n\tsetTimeout(() => {\n\t\tabortController.abort();\n\t}, 500);\n\n\ttry {\n\t\tawait delay(1000, {signal: abortController.signal});\n\t} catch (error) {\n\t\t// 500 milliseconds later\n\t\tconsole.log(error.name)\n\t\t//=> 'AbortError'\n\t}\n})();\n```\n\nCreate a new instance that is unaffected by libraries such as [lolex](https://github.com/sinonjs/lolex/):\n\n```js\nconst delay = require('delay');\n\nconst customDelay = delay.createWithTimers({clearTimeout, setTimeout});\n\n(async() => {\n\tconst result = await customDelay(100, {value: 'πŸ¦„'});\n\n\t// Executed after 100 milliseconds\n\tconsole.log(result);\n\t//=> 'πŸ¦„'\n})();\n```\n\n\n## Related\n\n- [delay-cli](https://github.com/sindresorhus/delay-cli) - CLI for this module\n- [p-cancelable](https://github.com/sindresorhus/p-cancelable) - Create a promise that can be canceled\n- [p-min-delay](https://github.com/sindresorhus/p-min-delay) - Delay a promise a minimum amount of time\n- [p-immediate](https://github.com/sindresorhus/p-immediate) - Returns a promise resolved in the next event loop - think `setImmediate()`\n- [p-timeout](https://github.com/sindresorhus/p-timeout) - Timeout a promise after a specified amount of time\n- [More…](https://github.com/sindresorhus/promise-fun)\n\n\n## License\n\nMIT Β© [Sindre Sorhus](https://sindresorhus.com)\n", "readmeFilename": "readme.md", "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/delay.git" }, "scripts": { "test": "xo && ava && tsd" }, "version": "4.2.0" }