Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

manvalls/vz.resolve

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vz resolve

DEPRECATED in favour of vz.yielded

NPM

No piece of software is ever completed, feel free to contribute and be humble

Sample usage:

var resolve = require('vz.resolve'),
    nextTick = require('vz.next-tick'),
    result;

result = resolve(function solve(){
  if(Math.random() < 0.5) this.resolve('Hello world');
  else nextTick(solve,[],this);
},function(data){
  console.log('Received asynchronously:',data);
});

if(result != resolve.deferred) console.log('Received synchronously:',result);

Reference

resolve(function[,arguments],callback[,thisArg])

This function executes function with arguments or an empty array as arguments, and a new Resolver as the thisArg. If Resolver.resolve is called within function, then this function returns the value passed to that call, otherwise it returns resolve.deferred, a unique object representing that the task could not be completed synchronously, and executes callback with thisArg as thisArg when Resolver.resolve is called.

About

Resolve operations that may be sync or async

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published