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

p-min-delay

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

p-min-delay - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

index.d.ts

24

index.js
'use strict';
const delay = require('delay');
module.exports = (promise, ms, opts) => {
opts = Object.assign({
delayRejection: true
}, opts);
const pMinDelay = async (promise, minimumDelay, options) => {
options = {
delayRejection: true,
...options
};
let promiseErr;
let promiseError;
if (opts.delayRejection) {
promise = promise.catch(err => {
promiseErr = err;
if (options.delayRejection) {
promise = promise.catch(error => {
promiseError = error;
});
}
return Promise.all([promise, delay(ms)])
.then(val => promiseErr ? Promise.reject(promiseErr) : val[0]);
const value = await Promise.all([promise, delay(minimumDelay)]);
return promiseError ? Promise.reject(promiseError) : value[0];
};
module.exports = pMinDelay;
module.exports.default = pMinDelay;
{
"name": "p-min-delay",
"version": "2.0.0",
"description": "Delay a promise a minimum amount of time",
"license": "MIT",
"repository": "sindresorhus/p-min-delay",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"promise",
"delay",
"minimum",
"min",
"resolve",
"stall",
"defer",
"wait",
"timeout",
"settimeout",
"event",
"loop",
"next",
"tick",
"delay",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"delay": "^1.3.1"
},
"devDependencies": {
"ava": "*",
"in-range": "^1.0.0",
"time-span": "^1.0.0",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "p-min-delay",
"version": "3.0.0",
"description": "Delay a promise a minimum amount of time",
"license": "MIT",
"repository": "sindresorhus/p-min-delay",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd-check"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"promise",
"delay",
"minimum",
"min",
"resolve",
"stall",
"defer",
"wait",
"timeout",
"settimeout",
"event",
"loop",
"next",
"tick",
"delay",
"async",
"await",
"promises",
"bluebird"
],
"dependencies": {
"delay": "^4.1.0"
},
"devDependencies": {
"ava": "^1.3.1",
"in-range": "^1.0.0",
"time-span": "^3.0.0",
"tsd-check": "^0.5.0",
"xo": "^0.24.0"
}
}

@@ -13,3 +13,3 @@ # p-min-delay [![Build Status](https://travis-ci.org/sindresorhus/p-min-delay.svg?branch=master)](https://travis-ci.org/sindresorhus/p-min-delay)

```
$ npm install --save p-min-delay
$ npm install p-min-delay
```

@@ -23,5 +23,6 @@

pMinDelay(somePromise, 1000).then(value => {
// executed after minimum 1 second even if `somePromise` fulfills before that
});
(async () => {
const value = await pMinDelay(somePromise, 1000);
// Executed after minimum 1 second even if `somePromise` fulfills before that
})();
```

@@ -32,5 +33,5 @@

### pMinDelay(input, minimumDelay, [options])
### pMinDelay(promise, minimumDelay, [options])
#### input
#### promise

@@ -37,0 +38,0 @@ Type: `Promise`

Sorry, the diff of this file is not supported yet

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