-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b60bf3c
Showing
8 changed files
with
2,457 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["es2015", "stage-3"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
### Node template | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage/ | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git | ||
node_modules/ | ||
|
||
.idea/ | ||
.nyc_output/ | ||
lib/ | ||
build/ | ||
doc/ | ||
stats/ | ||
|
||
# Created by .ignore support plugin (hsz.mobi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# suimin | ||
[![npm version](https://badge.fury.io/js/suimin.svg)](https://badge.fury.io/js/suimin) | ||
|
||
sleep function for javascript | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install suimin --save | ||
``` | ||
|
||
## Usage | ||
```javascript | ||
const suimin = require('suimin'); | ||
|
||
async function test() { | ||
console.log('Taking a break...'); | ||
await suimin(2000); | ||
console.log('Two second later'); | ||
} | ||
|
||
test(); | ||
``` | ||
|
||
## Test | ||
|
||
```bash | ||
npm install | ||
npm test | ||
``` | ||
|
||
|
||
## License | ||
[MIT license](http://opensource.org/licenses/mit-license.php) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function suimin(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
} | ||
|
||
module.exports = suimin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "suimin", | ||
"version": "0.1.1", | ||
"description": "sleep function for javascript", | ||
"main": "dist/suimin.js", | ||
"scripts": { | ||
"build": "webpack", | ||
"test": "mocha --compilers js:babel-register --require babel-polyfill test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/kokororin/suimin.git" | ||
}, | ||
"keywords": [ | ||
"javascript" | ||
], | ||
"author": "kokororin", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/kokororin/suimin/issues" | ||
}, | ||
"homepage": "https://github.com/kokororin/suimin#readme", | ||
"devDependencies": { | ||
"babel-core": "^6.23.1", | ||
"babel-loader": "^6.3.2", | ||
"babel-polyfill": "^6.23.0", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-stage-3": "^6.22.0", | ||
"mocha": "^3.2.0", | ||
"power-assert": "^1.4.2", | ||
"webpack": "1.x" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const assert = require('power-assert'); | ||
const suimin = require('.'); | ||
|
||
describe('suimin', function() { | ||
it('should sleep 1500ms', async function() { | ||
this.timeout(10000); | ||
const startTime = +new Date(); | ||
await suimin(1500); | ||
const endTime = +new Date(); | ||
assert.strictEqual((endTime - startTime) > 1500, true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const path = require('path'); | ||
const webpack = require('webpack'); | ||
|
||
const libraryName = 'suimin'; | ||
const outputFile = libraryName + '.js'; | ||
|
||
module.exports = { | ||
entry: path.resolve(__dirname, 'index.js'), | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
filename: outputFile, | ||
library: libraryName, | ||
libraryTarget: 'umd', | ||
umdNamedDefine: true | ||
}, | ||
module: { | ||
loaders: [{ | ||
test: /\.(js)$/, | ||
loader: 'babel-loader', | ||
exclude: /(node_modules|bower_components)/ | ||
}] | ||
}, | ||
plugins: [ | ||
new webpack.optimize.DedupePlugin(), | ||
new webpack.optimize.OccurrenceOrderPlugin(), | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compress: { | ||
warnings: false, | ||
drop_console: true | ||
}, | ||
beautify: false, | ||
comments: false | ||
}), | ||
], | ||
resolve: { extensions: ['', '.js'] } | ||
} |
Oops, something went wrong.