Sha256: 153453c4d84a3c2f13589c37055a7daff61d48475dcce554f7eedad15fc7b3e5

Contents?: true

Size: 905 Bytes

Versions: 1036

Compression:

Stored size: 905 Bytes

Contents

// Returns a wrapper function that returns a wrapped callback
// The wrapper function should do some stuff, and return a
// presumably different callback function.
// This makes sure that own properties are retained, so that
// decorations and such are not lost along the way.
module.exports = wrappy
function wrappy (fn, cb) {
  if (fn && cb) return wrappy(fn)(cb)

  if (typeof fn !== 'function')
    throw new TypeError('need wrapper function')

  Object.keys(fn).forEach(function (k) {
    wrapper[k] = fn[k]
  })

  return wrapper

  function wrapper() {
    var args = new Array(arguments.length)
    for (var i = 0; i < args.length; i++) {
      args[i] = arguments[i]
    }
    var ret = fn.apply(this, args)
    var cb = args[args.length-1]
    if (typeof ret === 'function' && ret !== cb) {
      Object.keys(cb).forEach(function (k) {
        ret[k] = cb[k]
      })
    }
    return ret
  }
}

Version data entries

1,036 entries across 414 versions & 47 rubygems

Version Path
rapid_stack-0.2.0 templates/frontend/node_modules/wrappy/wrappy.js
rapid_stack-0.1.1 templates/FrontEnd/node_modules/wrappy/wrappy.js
rapid_stack-0.1.0 templates/FrontEnd/node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.60 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.59 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.58 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.57 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.56 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.55 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.54 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.53 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.52 node_modules/wrappy/wrappy.js
trusty-cms-6.3.1 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.51 node_modules/wrappy/wrappy.js
boring_generators-0.15.0 tmp/templates/app_template/node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.50 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.49 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.48 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.47 node_modules/wrappy/wrappy.js
immosquare-cleaner-0.1.46 node_modules/wrappy/wrappy.js