├── .gitignore ├── LICENSE ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | npm-debug.log 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Trung Nguyen (http://meo.guru) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # then-sleep 2 | 3 | Promise-based sleeping. 4 | 5 | ## Installation 6 | 7 | ```sh 8 | npm i then-sleep -S 9 | ``` 10 | 11 | ## Usage 12 | 13 | ```js 14 | var sleep = require('then-sleep'); 15 | 16 | // Sleep for 1 second and do something then. 17 | sleep(1000).then(...); 18 | ``` 19 | 20 | ## License 21 | 22 | MIT licensed. 23 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var Promise = require('native-or-bluebird'); 4 | 5 | module.exports = function (ms) { 6 | return new Promise(function (resolve) { 7 | setTimeout(resolve, ms); 8 | }); 9 | }; 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "then-sleep", 3 | "version": "1.0.1", 4 | "description": "Promise-based sleeping.", 5 | "keywords": [ 6 | "sleep", 7 | "promise" 8 | ], 9 | "license": "MIT", 10 | "author": "Trung Nguyen (http://meo.guru)", 11 | "files": [ 12 | "index.js" 13 | ], 14 | "repository": "meoguru/then-sleep-js", 15 | "dependencies": { 16 | "native-or-bluebird": "^1.2.0" 17 | } 18 | } 19 | --------------------------------------------------------------------------------