-
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
Evheniy Bystrov
committed
Feb 5, 2017
1 parent
26f16be
commit 5565e99
Showing
9 changed files
with
130 additions
and
1 deletion.
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 @@ | ||
service_name: travis-ci | ||
src_dir: . | ||
coverage_clover: coverage/coverage.raw.json |
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 @@ | ||
module.exports = { | ||
"env": { | ||
"es6": true, | ||
"node": true, | ||
"mocha": true, | ||
}, | ||
"globals": { | ||
"fetch": true, | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 8, | ||
"sourceType": "module", | ||
}, | ||
"rules": { | ||
"indent": [ | ||
"error", | ||
4, | ||
{ | ||
"SwitchCase": 1, | ||
}, | ||
], | ||
"linebreak-style": [ | ||
"error", | ||
"unix", | ||
], | ||
"quotes": [ | ||
"error", | ||
"single", | ||
], | ||
"semi": [ | ||
"error", | ||
"always", | ||
], | ||
} | ||
}; |
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 @@ | ||
coverage | ||
.idea | ||
npm-debug.log | ||
node_modules | ||
.DS_Store |
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 @@ | ||
instrumentation: | ||
default-excludes: true | ||
include-all-sources: 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,5 @@ | ||
language: node_js | ||
node_js: | ||
- 7 | ||
script: | ||
- npm test && npm run report-coverage |
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 |
---|---|---|
@@ -1,2 +1,25 @@ | ||
# promise-timeout | ||
Promise timeout | ||
=========================== | ||
|
||
It could be useful when you need to make pause in promise pipeline | ||
|
||
|
||
[![Build Status](https://travis-ci.org/evheniy/promise-timeout.svg?branch=master)](https://travis-ci.org/evheniy/promise-timeout) | ||
[![Coverage Status](https://coveralls.io/repos/github/evheniy/promise-timeout/badge.svg?branch=master)](https://coveralls.io/github/evheniy/promise-timeout?branch=master) | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
npm i -S promise-timeout | ||
|
||
Example | ||
------- | ||
|
||
const pause = require('promise-timeout'); | ||
|
||
(async () => { | ||
const data1 = await fetch(url1); | ||
await pause(1000); | ||
const data2 = await fetch(url2); | ||
})(); |
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 @@ | ||
module.exports = ms => new Promise(resolve => setTimeout(resolve, ms)); |
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,39 @@ | ||
{ | ||
"name": "promise-timeout", | ||
"description": "Promise timeout", | ||
"repository": "evheniy/promise-timeout", | ||
"version": "0.0.1", | ||
"scripts": { | ||
"test": "npm run security && npm run clear && npm run lint && npm run coverage", | ||
"lint": "./node_modules/.bin/eslint index.js tests", | ||
"coverage": "node --harmony ./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- tests --recursive", | ||
"report-coverage": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls", | ||
"clear": "./node_modules/.bin/rimraf coverage", | ||
"security": "./node_modules/.bin/nsp check" | ||
}, | ||
"engines": { | ||
"node": ">=7.0.0" | ||
}, | ||
"keywords": [ | ||
"promise", | ||
"timeout", | ||
"setTimeout", | ||
"async", | ||
"await" | ||
], | ||
"files": [ | ||
"index.js" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.11.15", | ||
"eslint": "^3.14.1", | ||
"istanbul": "^1.1.0-alpha.1", | ||
"mocha": "^3.2.0", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"nsp": "^2.6.2", | ||
"rimraf": "^2.5.4" | ||
}, | ||
"license": "MIT" | ||
} |
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,14 @@ | ||
const expect = require('chai').expect; | ||
const promise = require('../index'); | ||
|
||
|
||
describe('Promise timeout test', () => { | ||
it('it should test promise timeout', async () => { | ||
const start = new Date; | ||
await promise(1000); | ||
const ms = new Date - start; | ||
|
||
expect(ms).to.be.above(1000); | ||
expect(ms).to.be.below(2000); | ||
}); | ||
}); |