Skip to content

cravler/function.prototype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

function.prototype

Function prototype extensions

Install

This package depends on Node.js.

$ npm install function.prototype

Usage

isGenerator

var fpt = require('function.prototype');

fpt.isGenerator(function * () {}); // true
fpt.isGenerator(function () {}); // false

// or

fpt.isGenerator.shim();

function * () {}.isGenerator(); // true
function () {}.isGenerator(); // false

promisify

var fpt = require('function.prototype');

fpt.promisify(function * (key) { return key }).call(null, 'key').then(function(key) {}, function(err) {});
fpt.promisify(function (key, cb) { cb(null, key) }).call(null, 'key').then(function(key) {}, function(err) {});

// or

fpt.promisify.shim();

function * (key) { return key }.promisify().call(null, 'key').then(function(key) {}, function(err) {});
function (key, cb) { cb(null, key) }.promisify().call(null, 'key').then(function(key) {}, function(err) {});

License

This software is under the MIT license. See the complete license in:

LICENSE

About

Function prototype extensions

Resources

License

Stars

Watchers

Forks

Packages

No packages published