cocos2d-x/cocos/scripting/js-bindings/script/debugger/core/promise.js
/**
    Returns a wrapped `f`, which when called returns a promise that resolves to
    `f(...)` passing all the given arguments to it, which by the way may be
    promises. Optionally second `prototype` argument may be provided to be used
    a prototype for a returned promise.

    ## Example

    var promise = promised(Array)(1, promise(2), promise(3))
    promise.then(console.log) // => [ 1, 2, 3 ]
    **/
Returns a wrapped `f`, which when called returns a promise that resolves to
`f(...)` passing all the given arguments to it, which by the way may be
promises. Optionally second `prototype` argument may be provided to be used
a prototype for a returned promise.

Example


Returns a wrapped ` f ` which when called returns a promise that resolves to ` f ( ... ) ` passing all the given arguments to it which by the way may be promises . Optionally second ` prototype ` argument may be provided to be used a prototype for a returned promise . Example
function promised() {
      return concat.apply([ f, this ], arguments).
        reduce(promisedConcat, resolve([], prototype)).
        then(execute);
    }
function promised ( ) { return concat . apply ( [ f , this ] , arguments ) . reduce ( promisedConcat , resolve ( [ ] , prototype ) ) . then ( execute ) ; }
Returns a wrapped `f`, which when called returns a promise that resolves to
`f(...)` passing all the given arguments to it, which by the way may be
promises.
Returns a wrapped ` f ` which when called returns a promise that resolves to ` f ( ... ) ` passing all the given arguments to it which by the way may be promises .
// create array of [ f, this, args... ] // reduce it via `promisedConcat` to get promised array of fulfillments // finally map that to promise of `f.apply(this, args...)`