Skip to content

hgl/unbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

unbox

Extract values "boxed" inside objects like generators, generator functions, thunks, etc. Help you write asynchronous code more elegantly.

Inspired by co. The main difference is that any value is yieldable in unbox and parallel execution is optional.

Installation

npm install unbox

Generators and generator functions

unbox itself only uses es5 features, but to create generators and generator functions, you need to use node 0.11.x with the --harmony-generators (or --harmony) flag.

Example

var foo = function* () {
	return yield 1;
};

unbox(foo(), function (err, val) {
	console.log(val); // 1
});
unbox(function* () {
	var foo = yield 1;
	console.log(foo); // 1
});
var fn = function (done) {
	setTimeout(function () {
		done(null, 1);
	}, 0);
};
unbox();

About

Help you write asynchronous code more elegantly.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published