Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-delay

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-delay - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

circle.yml

9

index.js

@@ -13,2 +13,11 @@ if (!global.Promise) {

function delayedReject (delay, val) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
reject(val)
}, delay)
})
}
module.exports = promiseDelay
module.exports.reject = delayedReject

4

package.json
{
"name": "promise-delay",
"author": "jden <jason@denizac.org>",
"version": "2.0.0",
"version": "2.1.0",
"engines": {
"node": ">=0.12"
},
"description": "like Promise.cast with a delay in milliseconds",
"description": "like Promise.resolve with a delay in milliseconds",
"keywords": [

@@ -10,0 +10,0 @@ "promise",

# promise-delay
like Promise.cast with a delay in milliseconds
like Promise.resolve with a delay in milliseconds

@@ -14,3 +14,3 @@ [![Circle CI](https://circleci.com/gh/jden/node-promise-delay.svg?style=svg)](https://circleci.com/gh/jden/node-promise-delay)

var eventually = promiseDelay(100, Promise.cast('foo'))
var eventually = promiseDelay(100, Promise.resolve('foo'))

@@ -27,3 +27,12 @@ eventually.then(next)

})
```
or, reject after a delay:
```js
var rejected = promiseDelay.reject(100, new Error('rejected'))
rejected.catch(function (err) {
console.log(err)
// Error: rejected
})
```

@@ -30,0 +39,0 @@

@@ -27,2 +27,18 @@ /* globals describe, it */

})
describe('.reject', function () {
it('rejects after a delay', function (end) {
var start = Date.now()
var err = new Error('blah')
promiseDelay.reject(100, err)
.then(function () {
throw new Error('should not resolve')
}, function (e) {
expect(e).to.equal(err)
var elapsed = Date.now() - start
expect(elapsed).to.be.within(90, 110)
})
.then(end, end)
})
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc