Socket
Socket
Sign inDemoInstall

p-defer

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.1 to 2.1.0

65

index.d.ts

@@ -1,25 +0,54 @@

export interface DeferredPromise<ValueType> {
/**
Resolves the promise with a value or the result of another promise.
declare namespace pDefer {
interface DeferredPromise<ValueType> {
/**
Resolves the promise with a value or the result of another promise.
@param value - The value to resolve the promise with.
*/
resolve(value?: ValueType | PromiseLike<ValueType>): void;
@param value - The value to resolve the promise with.
*/
resolve(value?: ValueType | PromiseLike<ValueType>): void;
/**
Reject the promise with a provided reason or error.
@param reason - The reason or error to reject the promise with.
*/
reject(reason?: unknown): void;
/**
The deferred promise.
*/
promise: Promise<ValueType>;
}
}
declare const pDefer: {
/**
Reject the promise with a provided reason or error.
Create a deferred promise.
@param reason - The reason or error to reject the promise with.
*/
reject(reason?: unknown): void;
@example
```
import pDefer = require('p-defer');
/**
The deferred promise.
function delay(ms) {
const deferred = pDefer();
setTimeout(deferred.resolve, ms, '🦄');
return deferred.promise;
}
(async () => {
console.log(await delay(100));
//=> '🦄'
})();
```
*/
promise: Promise<ValueType>;
}
<ValueType = unknown>(): pDefer.DeferredPromise<ValueType>;
/**
Create a deferred promise.
*/
export default function pDefer<ValueType = unknown>(): DeferredPromise<ValueType>;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function pDefer<ValueType = unknown>(): pDefer.DeferredPromise<
// ValueType
// >;
// export = pDefer;
default: typeof pDefer;
};
export = pDefer;

@@ -15,2 +15,3 @@ 'use strict';

module.exports = pDefer;
// TODO: Remove this for the next major release
module.exports.default = pDefer;
{
"name": "p-defer",
"version": "2.0.1",
"version": "2.1.0",
"description": "Create a deferred promise",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -37,6 +37,6 @@ "files": [

"devDependencies": {
"ava": "^1.3.1",
"tsd-check": "^0.5.0",
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc