p-min-delay
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -1,32 +0,47 @@ | ||
export interface Options { | ||
/** | ||
Delay the rejection. | ||
declare namespace pMinDelay { | ||
interface Options { | ||
/** | ||
Delay the rejection. | ||
Turn this off if you want a rejected promise to fail fast. | ||
Turn this off if you want a rejected promise to fail fast. | ||
@default true | ||
*/ | ||
readonly delayRejection?: boolean; | ||
@default true | ||
*/ | ||
readonly delayRejection?: boolean; | ||
} | ||
} | ||
/** | ||
Delay a promise a minimum amount of time. | ||
declare const pMinDelay: { | ||
/** | ||
Delay a promise a minimum amount of time. | ||
@param promise - Promise to delay. | ||
@param minimumDelay - Time in milliseconds. | ||
@param promise - Promise to delay. | ||
@param minimumDelay - Time in milliseconds. | ||
@example | ||
``` | ||
import pMinDelay from 'p-min-delay'; | ||
@example | ||
``` | ||
import pMinDelay = require('p-min-delay'); | ||
(async () => { | ||
const value = await pMinDelay(somePromise, 1000); | ||
// Executed after minimum 1 second even if `somePromise` fulfills before that | ||
})(); | ||
``` | ||
*/ | ||
export default function pMinDelay<ValueType>( | ||
promise: PromiseLike<ValueType>, | ||
minimumDelay: number, | ||
options?: Options | ||
): Promise<ValueType>; | ||
(async () => { | ||
const value = await pMinDelay(somePromise, 1000); | ||
// Executed after minimum 1 second even if `somePromise` fulfills before that | ||
})(); | ||
``` | ||
*/ | ||
<ValueType>( | ||
promise: PromiseLike<ValueType>, | ||
minimumDelay: number, | ||
options?: pMinDelay.Options | ||
): Promise<ValueType>; | ||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function pMinDelay<ValueType>( | ||
// promise: PromiseLike<ValueType>, | ||
// minimumDelay: number, | ||
// options?: pMinDelay.Options | ||
// ): Promise<ValueType>; | ||
// export = pMinDelay; | ||
default: typeof pMinDelay; | ||
}; | ||
export = pMinDelay; |
@@ -23,2 +23,3 @@ 'use strict'; | ||
module.exports = pMinDelay; | ||
// TODO: Remove this for the next major release | ||
module.exports.default = pMinDelay; |
{ | ||
"name": "p-min-delay", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Delay a promise a minimum amount of time", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
"test": "xo && ava && tsd" | ||
}, | ||
@@ -48,8 +48,8 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"ava": "^1.4.1", | ||
"in-range": "^1.0.0", | ||
"time-span": "^3.0.0", | ||
"tsd-check": "^0.5.0", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
5257
58