{"_id":"p-lazy","_rev":"269842","name":"p-lazy","description":"Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2021-06-03T17:18:39.000Z","created":"2016-11-07T09:23:20.098Z","4.0.0":"2021-04-09T06:17:34.889Z","3.1.0":"2021-01-10T17:43:20.145Z","3.0.0":"2019-04-03T05:29:27.612Z","2.0.0":"2019-03-16T18:35:47.293Z","1.0.0":"2016-11-07T09:23:20.098Z"},"users":{"rocket0191":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-lazy.git"},"versions":{"4.0.0":{"name":"p-lazy","version":"4.0.0","description":"Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-lazy.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","lazy","defer","deferred","then","catch","fulfilled","async","function","await","promises","bluebird"],"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","tsd":"^0.14.0","xo":"^0.38.2"},"gitHead":"ec4791753111d7c01f44f8dffed21327bef46081","bugs":{"url":"https://github.com/sindresorhus/p-lazy/issues"},"homepage":"https://github.com/sindresorhus/p-lazy#readme","_id":"p-lazy@4.0.0","_nodeVersion":"15.12.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"744f02310f3eab92b465873a841f39384d8a0458","size":2221,"noattachment":false,"key":"/p-lazy/-/p-lazy-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-lazy/download/p-lazy-4.0.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-lazy_4.0.0_1617949054762_0.7405464468303842"},"_hasShrinkwrap":false,"publish_time":1617949054889,"_cnpm_publish_time":1617949054889},"3.1.0":{"name":"p-lazy","version":"3.1.0","description":"Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-lazy.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","lazy","defer","deferred","then","catch","fulfilled","async","function","await","promises","bluebird"],"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"b256354e814b99fb200773c8e292ed4da851b8e9","bugs":{"url":"https://github.com/sindresorhus/p-lazy/issues"},"homepage":"https://github.com/sindresorhus/p-lazy#readme","_id":"p-lazy@3.1.0","_nodeVersion":"15.5.0","_npmVersion":"6.14.10","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"4b1e40482b7ee87853abbcf31824ff64e1816d61","size":2216,"noattachment":false,"key":"/p-lazy/-/p-lazy-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-lazy/download/p-lazy-3.1.0.tgz"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-lazy_3.1.0_1610300600000_0.9653662740555646"},"_hasShrinkwrap":false,"publish_time":1610300600145,"_cnpm_publish_time":1610300600145},"3.0.0":{"name":"p-lazy","version":"3.0.0","description":"Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-lazy.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","lazy","defer","deferred","then","catch","fulfilled","async","function","await","promises","bluebird"],"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"2d38e9173d41021c7088ee3b60b0230143c60f78","bugs":{"url":"https://github.com/sindresorhus/p-lazy/issues"},"homepage":"https://github.com/sindresorhus/p-lazy#readme","_id":"p-lazy@3.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"3d8b2aceea3e49f8e5883947838e9370f15c9e28","size":2163,"noattachment":false,"key":"/p-lazy/-/p-lazy-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-lazy/download/p-lazy-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-lazy_3.0.0_1554269367472_0.6063293656935744"},"_hasShrinkwrap":false,"publish_time":1554269367612,"_cnpm_publish_time":1554269367612},"2.0.0":{"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":{"type":"git","url":"git+https://github.com/sindresorhus/p-lazy.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=6"},"scripts":{"test":"xo && ava && tsd-check"},"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"},"gitHead":"71d69db945e112a23ceaf7f9482ed307efd02c7e","bugs":{"url":"https://github.com/sindresorhus/p-lazy/issues"},"homepage":"https://github.com/sindresorhus/p-lazy#readme","_id":"p-lazy@2.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"6501a84a49ae07f352deabd84ab447867b06afa2","size":2091,"noattachment":false,"key":"/p-lazy/-/p-lazy-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-lazy/download/p-lazy-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-lazy_2.0.0_1552761347094_0.4100894551311418"},"_hasShrinkwrap":false,"publish_time":1552761347293,"_cnpm_publish_time":1552761347293},"1.0.0":{"name":"p-lazy","version":"1.0.0","description":"Create a lazy promise that defers execution until `.then()` or `.catch()` is called","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-lazy.git"},"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},"gitHead":"9d240009f7ecc2217889304e7cfe4f21d985e442","bugs":{"url":"https://github.com/sindresorhus/p-lazy/issues"},"homepage":"https://github.com/sindresorhus/p-lazy#readme","_id":"p-lazy@1.0.0","_shasum":"ec53c802f2ee3ac28f166cc82d0b2b02de27a835","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.1","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"ec53c802f2ee3ac28f166cc82d0b2b02de27a835","size":1911,"noattachment":false,"key":"/p-lazy/-/p-lazy-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-lazy/download/p-lazy-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-lazy-1.0.0.tgz_1478510599877_0.9282662672922015"},"directories":{},"publish_time":1478510600098,"_cnpm_publish_time":1478510600098,"_hasShrinkwrap":false}},"readme":"# p-lazy\n\n> Create a lazy promise that defers execution until it's awaited or when `.then()` or `.catch()` is called\n\nUseful if you're doing some heavy operations and would like to only do it when the promise is actually used.\n\n## Install\n\n```\n$ npm install p-lazy\n```\n\n## Usage\n\n```js\nimport PLazy from 'p-lazy';\n\nconst lazyPromise = new PLazy(resolve => {\n\tsomeHeavyOperation(resolve);\n});\n\n// `someHeavyOperation` is not yet called\n\nawait doSomethingFun;\n\n// `someHeavyOperation` is called\nconsole.log(await lazyPromise);\n```\n\n## API\n\n### new PLazy(executor)\n\nSame as the [`Promise` constructor](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise). `PLazy` is a subclass of `Promise`.\n\n### PLazy.from(fn)\n\nCreate a `PLazy` promise from a promise-returning or async function.\n\n### PLazy.resolve(value)\n\nCreate a `PLazy` promise that is resolved with the given `value`, or the promise passed as `value`.\n\n### PLazy.reject(reason)\n\nCreate a `PLazy` promise that is rejected with the given `reason`.\n\n## Related\n\n- [p-cancelable](https://github.com/sindresorhus/p-cancelable) - Create a promise that can be canceled\n- [p-defer](https://github.com/sindresorhus/p-defer) - Create a deferred promise\n- [lazy-value](https://github.com/sindresorhus/lazy-value) - Create a lazily evaluated value\n- [define-lazy-prop](https://github.com/sindresorhus/define-lazy-prop) - Define a lazily evaluated property on an object\n- [More…](https://github.com/sindresorhus/promise-fun)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/p-lazy#readme","bugs":{"url":"https://github.com/sindresorhus/p-lazy/issues"},"license":"MIT"}