Comparing version 1.0.0 to 2.0.0
@@ -12,2 +12,3 @@ 'use strict'; | ||
} | ||
static from(fn) { | ||
@@ -18,2 +19,3 @@ return new PLazy(resolve => { | ||
} | ||
then(onFulfilled, onRejected) { | ||
@@ -23,2 +25,3 @@ this._promise = this._promise || new Promise(this._executor); | ||
} | ||
catch(onRejected) { | ||
@@ -31,1 +34,2 @@ this._promise = this._promise || new Promise(this._executor); | ||
module.exports = PLazy; | ||
module.exports.default = PLazy; |
{ | ||
"name": "p-lazy", | ||
"version": "1.0.0", | ||
"description": "Create a lazy promise that defers execution until `.then()` or `.catch()` is called", | ||
"license": "MIT", | ||
"repository": "sindresorhus/p-lazy", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"promise", | ||
"lazy", | ||
"defer", | ||
"deferred", | ||
"then", | ||
"catch", | ||
"fulfilled", | ||
"async", | ||
"function", | ||
"await", | ||
"promises", | ||
"bluebird" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"delay": "^1.3.1", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "p-lazy", | ||
"version": "2.0.0", | ||
"description": "Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called", | ||
"license": "MIT", | ||
"repository": "sindresorhus/p-lazy", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"promise", | ||
"lazy", | ||
"defer", | ||
"deferred", | ||
"then", | ||
"catch", | ||
"fulfilled", | ||
"async", | ||
"function", | ||
"await", | ||
"promises", | ||
"bluebird" | ||
], | ||
"devDependencies": { | ||
"ava": "^1.3.1", | ||
"delay": "^4.1.0", | ||
"tsd-check": "^0.4.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
# p-lazy [![Build Status](https://travis-ci.org/sindresorhus/p-lazy.svg?branch=master)](https://travis-ci.org/sindresorhus/p-lazy) | ||
> Create a lazy promise that defers execution until `.then()` or `.catch()` is called | ||
> Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called | ||
@@ -11,3 +11,3 @@ Useful if you're doing some heavy operations and would like to only do it when the promise is actually used. | ||
``` | ||
$ npm install --save p-lazy | ||
$ npm install p-lazy | ||
``` | ||
@@ -27,6 +27,7 @@ | ||
doSomethingFun.then(() => { | ||
(async () => { | ||
await doSomethingFun; | ||
// `someHeavyOperation` is called | ||
lazyPromise.then(console.log); | ||
}); | ||
console.log(await lazyPromise); | ||
})(); | ||
``` | ||
@@ -48,3 +49,6 @@ | ||
- [p-cancelable](https://github.com/sindresorhus/p-cancelable) - Create a promise that can be canceled | ||
- [p-defer](https://github.com/sindresorhus/p-defer) - Create a deferred promise | ||
- [lazy-value](https://github.com/sindresorhus/lazy-value) - Create a lazily evaluated value | ||
- [define-lazy-prop](https://github.com/sindresorhus/define-lazy-prop) - Define a lazily evaluated property on an object | ||
- [More…](https://github.com/sindresorhus/promise-fun) | ||
@@ -51,0 +55,0 @@ |
Sorry, the diff of this file is not supported yet
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
4294
5
36
57
4