You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

generator-wrap

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

generator-wrap

Wrapper for generators to transform them in coroutines.

2.0.0
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

generator-wrap Build Status

Wrapper for generators to transform them in coroutines.

Installation

$ npm install generator-wrap

Example

var wrap = require('generator-wrap');

function someAsyncOperation() {
	return new Promise(function(resolve, reject){
		setTimeout(function(){
			resolve(3.1415);
		}, 1000);
	});
}

wrap(function*(){
	console.log('Hello World from a coroutine!');
	var asyncObtainedValue = yield someAsyncOperation();
	console.log('Async Value: '+asyncObtainedValue);
})();

API

wrap(generatorFunction)

Wraps the generator in a function that is returned. When the function is executed, yielded values are treated as promises and their resolved values or their rejected errors are passed back in the generator.

License

MIT

Keywords

generator

FAQs

Package last updated on 08 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts