Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kokororin committed Feb 20, 2017
0 parents commit b60bf3c
Show file tree
Hide file tree
Showing 8 changed files with 2,457 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "stage-3"]
}
38 changes: 38 additions & 0 deletions .gitignore
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)
34 changes: 34 additions & 0 deletions README.md
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)
5 changes: 5 additions & 0 deletions index.js
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;
33 changes: 33 additions & 0 deletions package.json
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"
}
}
12 changes: 12 additions & 0 deletions test.js
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);
});
});
36 changes: 36 additions & 0 deletions webpack.config.js
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'] }
}
Loading

0 comments on commit b60bf3c

Please sign in to comment.