@perf-tools/promise
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

@perf-tools/promise

Lazy Promise creates native Promise only if you use then or catch methods.

npm i --save @perf-tools/promise

Usage

import { LazyPromise } from '@perf-tools/promise';

const lazy = new LazyPromise((resolve) => {
	resolve('LAZY!');
});

console.log('Like native:', lazy instanceof Promise); // Like native: true
console.log('Lazy?', lazy instanceof LazyPromise); // Lazy? true

// Activation (create Native Promise)
lazy.then((val) => {
	console.log('result:', val); // result: LAZY!
});

Development

Readme

Keywords

Package Sidebar

Install

npm i @perf-tools/promise

Weekly Downloads

5

Version

0.1.1

License

MIT

Unpacked Size

14.2 kB

Total Files

8

Last publish

Collaborators

  • rubaxa