Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

nailgun/q-lazy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Q.lazy()

Promises/A+ logo

Resolves promises idly.

Build Status NPM version

npm install q-lazy

About

It's a simple plugin for Q allowing you to create lazy promises. Such promises start to resolve only after calling .then() on them.

Usage

var Q = require('q');
require('q-lazy'); // extends Q

function heavyFunc () {
    // ...
    return ret; // the return value can be a promise or a plain value
}

var promise = Q.lazy(heavyFunc); // doesn't execute heavyFunc

promise.then(function (ret) {    // executes heavyFunc
    // use ret
});

For specification take a look at provided testsuite. It's short.

About

Q lazy promise resolution

Resources

License

Stars

Watchers

Forks

Packages

No packages published