Comparing version 2.0.0 to 3.0.0
/** | ||
Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called. | ||
*/ | ||
export default class PLazy<ValueType> extends Promise<ValueType> { | ||
declare class PLazy<ValueType> extends Promise<ValueType> { | ||
/** | ||
Create a `PLazy` promise from a promise-returning or async function. | ||
@example | ||
``` | ||
import PLazy = require('p-lazy'); | ||
const lazyPromise = new PLazy(resolve => { | ||
someHeavyOperation(resolve); | ||
}); | ||
// `someHeavyOperation` is not yet called | ||
(async () => { | ||
await doSomethingFun; | ||
// `someHeavyOperation` is called | ||
console.log(await lazyPromise); | ||
})(); | ||
``` | ||
*/ | ||
@@ -12,1 +29,3 @@ static from<ValueType>( | ||
} | ||
export = PLazy; |
@@ -10,3 +10,2 @@ 'use strict'; | ||
this._executor = executor; | ||
this._promise = null; | ||
} | ||
@@ -22,2 +21,3 @@ | ||
this._promise = this._promise || new Promise(this._executor); | ||
// eslint-disable-next-line promise/prefer-await-to-then | ||
return this._promise.then(onFulfilled, onRejected); | ||
@@ -33,2 +33,1 @@ } | ||
module.exports = PLazy; | ||
module.exports.default = PLazy; |
{ | ||
"name": "p-lazy", | ||
"version": "2.0.0", | ||
"version": "3.0.0", | ||
"description": "Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called", | ||
@@ -13,6 +13,6 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
"test": "xo && ava && tsd" | ||
}, | ||
@@ -38,7 +38,7 @@ "files": [ | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"ava": "^1.4.1", | ||
"delay": "^4.1.0", | ||
"tsd-check": "^0.4.0", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4594
49