pax_global_header00006660000000000000000000000064140101647360014514gustar00rootroot0000000000000052 comment=4ae31dde3a7431e377e3268e457687ea74bb0c40 yoctodelay-1.2.0/000077500000000000000000000000001401016473600136705ustar00rootroot00000000000000yoctodelay-1.2.0/.editorconfig000066400000000000000000000002571401016473600163510ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 yoctodelay-1.2.0/.gitattributes000066400000000000000000000000231401016473600165560ustar00rootroot00000000000000* text=auto eol=lf yoctodelay-1.2.0/.github/000077500000000000000000000000001401016473600152305ustar00rootroot00000000000000yoctodelay-1.2.0/.github/workflows/000077500000000000000000000000001401016473600172655ustar00rootroot00000000000000yoctodelay-1.2.0/.github/workflows/main.yml000066400000000000000000000006641401016473600207420ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 14 - 12 - 10 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test yoctodelay-1.2.0/.gitignore000066400000000000000000000000271401016473600156570ustar00rootroot00000000000000node_modules yarn.lock yoctodelay-1.2.0/.npmrc000066400000000000000000000000231401016473600150030ustar00rootroot00000000000000package-lock=false yoctodelay-1.2.0/index.d.ts000066400000000000000000000005121401016473600155670ustar00rootroot00000000000000/** Delay the promise and then resolve. @param milliseconds - The duration to delay the promise. @example ``` import delay = require('yoctodelay'); (async () => { foo(); await delay(100); // Executed 100 milliseconds later bar(); })(); ``` */ declare function delay(milliseconds: number): Promise; export = delay; yoctodelay-1.2.0/index.js000066400000000000000000000000611401016473600153320ustar00rootroot00000000000000module.exports=d=>new Promise(r=>setTimeout(r,d))yoctodelay-1.2.0/index.test-d.ts000066400000000000000000000001461401016473600165470ustar00rootroot00000000000000import {expectType} from 'tsd'; import delay = require ('.'); expectType>(delay(100)); yoctodelay-1.2.0/license000066400000000000000000000021351401016473600152360ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) 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. yoctodelay-1.2.0/package.json000066400000000000000000000015141401016473600161570ustar00rootroot00000000000000{ "name": "yoctodelay", "version": "1.2.0", "description": "Delay a promise a specified amount of time", "license": "MIT", "repository": "sindresorhus/yoctodelay", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "engines": { "node": ">=4" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "promise", "resolve", "delay", "defer", "wait", "stall", "timeout", "settimeout", "event", "loop", "next", "tick", "delay", "async", "await", "promises", "bluebird" ], "devDependencies": { "ava": "^2.4.0", "in-range": "^1.0.0", "time-span": "^2.0.0", "tsd": "^0.14.0", "xo": "^0.24.0" }, "xo": { "rules": { "eol-last": 0 }, "ignores": [ "index.js" ] } } yoctodelay-1.2.0/readme.md000066400000000000000000000022401401016473600154450ustar00rootroot00000000000000# yoctodelay > Delay a promise a specified amount of time It's less than half the size of the [`nanodelay`](https://github.com/ai/nanodelay) module. ## Install ``` $ npm install yoctodelay ``` ## Usage ```js const delay = require('yoctodelay'); (async () => { foo(); await delay(100); // Executed 100 milliseconds later bar(); })(); ``` ## API ### delay(milliseconds) Delay the promise and then resolve. #### milliseconds Type: `number` The duration to delay the promise. ## FAQ ### What is yocto? [It's the smallest official unit prefix in the metric system.](https://en.wikipedia.org/wiki/Yocto-) Much smaller than nano. ### Is this a joke? Partly. The `nanodelay` module was created only because the `delay` module is a tiny bit larger. Well, this module is a tiny bit smaller than the `nanodelay` module. Comparing size at the byte level is super silly. It doesn't matter unless the difference is more than many kilobytes. This is still a fully working module though. Go ahead and use it. ## Related - [delay](https://github.com/sindresorhus/delay) - Similar to this module but with more features - [More…](https://github.com/sindresorhus/promise-fun) yoctodelay-1.2.0/test.js000066400000000000000000000003661401016473600152120ustar00rootroot00000000000000import {serial as test} from 'ava'; import timeSpan from 'time-span'; import inRange from 'in-range'; import delay from '.'; test('main', async t => { const end = timeSpan(); await delay(50); t.true(inRange(end(), 30, 70), 'is delayed'); });