npm.io
0.1.1 • Published 8 years ago

function.prototype

Licence
MIT
Version
0.1.1
Deps
2
Size
4 kB
Vulns
0
Weekly
0

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

Keywords