Skip to content

fedor/node-becky

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Becky converts callback-based functions to promise-based (promisifies) and vice versa (callbackify)

Install

npm install becky --save

Use

// basic example
var p = require('becky').promisify        // also require('becky').p
var pm = require('becky').promisifyMulti  // also require('becky').pm
var cb = require('becky').callbackify     // also require('becky').cb

// TBD

// use with async + co
var async = require('async')
var co = require('co')
var fs = require('fs')

co(function* () {
	var files = ['file1', 'file2', 'file3']
	var result = yield p(async.mapLimit)(files, 2, cb(co.wrap(
		fucntion* (file) {
			content = yield p(fs.readFile)(file)
			return file + ': ' + content
		}
	)))

	console.log('Read result:', result)
})

About

Promisify and callbackify functions

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published