promisen.js
function nodeify(task) {
    task = promisen(task);
    return nodeifyTask;

    function nodeifyTask(args, callback) {
      args = Array.prototype.slice.call(arguments);
      callback = (args[args.length - 1] instanceof Function) && args.pop();
      if (!callback) callback = NOP;
      var onResolve = callback.bind(this, null);
      var onReject = callback.bind(this);
      task.apply(this, args).then(onResolve, onReject);
    }
  }
function nodeify(task) {
    task = promisen(task);
    return nodeifyTask;

    function nodeifyTask(args, callback) {
      args = Array.prototype.slice.call(arguments);
      callback = (args[args.length - 1] instanceof Function) && args.pop();
      if (!callback) callback = NOP;
      var onResolve = callback.bind(this, null);
      var onReject = callback.bind(this);
      task.apply(this, args).then(onResolve, onReject);
    }
  }
function nodeify ( task ) { task = promisen ( task ) ; return nodeifyTask ; function nodeifyTask ( args , callback ) { args = Array . prototype . slice . call ( arguments ) ; callback = ( args [ args . length - 1 ] instanceof Function ) && args . pop ( ) ; if ( ! callback ) callback = NOP ; var onResolve = callback . bind ( this , null ) ; var onReject = callback . bind ( this ) ; task . apply ( this , args ) . then ( onResolve , onReject ) ; } }
creates a Node.js-style function from a promise-returning function or any object.

@class promisen
@static
@function nodeify
@param task {Function|Promise|thenable|*} promise-returning function or any object
@returns {Function} Node.js-style function
@example
var promisen = require("promisen");

var task = nodeify(func);

task(value, function(err, res) {...});

function func(value) {
return new Promise(function(resolve, reject) {...});
}
creates a Node . js - style function from a promise - returning function or any object .