Skip to content
/ q-wrap Public

Utility library to wrap async functions with last callback argument to promise returning functions

Notifications You must be signed in to change notification settings

arikon/q-wrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

q-wrap

Utility library to wrap async functions with last callback argument to promise returning functions.

Usage

Convert callback-based function

var convert = require('q-wrap').convert,
    fs = require('fs'),

    readFile = convert(fs.readFile);

readFile('test.txt')
    .then(function(content) {
        console.log(content);
    })
    .fail(function(err) {
        console.error('Error opening file: %s', err);
    })

Execute callback-based function

var execute = require('q-wrap').execute,
    fs = require('fs');

execute(fs.readFile, 'test.txt')
    .then(function(content) {
        console.log(content);
    })
    .fail(function(err) {
        console.error('Error opening file: %s', err);
    })

About

Utility library to wrap async functions with last callback argument to promise returning functions

Resources

Stars

Watchers

Forks

Packages

No packages published