Sha256: 153453c4d84a3c2f13589c37055a7daff61d48475dcce554f7eedad15fc7b3e5

Contents?: true

Size: 905 Bytes

Versions: 1025

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,025 entries across 403 versions & 46 rubygems

Version Path
gulp_assets-1.0.0.pre.3 template/node_modules/csswring/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
gulp_assets-1.0.0.pre.3 template/node_modules/gulp-sass/node_modules/node-sass/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
gulp_assets-1.0.0.pre.3 template/node_modules/css-mqpacker/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
gulp_assets-1.0.0.pre.3 template/node_modules/babel-core/node_modules/regenerator/node_modules/commoner/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
opal-0.8.1.rc1 stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
opal-0.8.1.rc1 stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/once/node_modules/wrappy/wrappy.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
hooch-0.3.0 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
opal-wedge-0.9.0.dev stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
opal-wedge-0.9.0.dev stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
opal-0.8.0 stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
opal-0.8.0 stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
opal-0.8.0.rc3 stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
opal-0.8.0.rc3 stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
opal-0.8.0.rc2 stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js
opal-0.8.0.rc2 stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/npmconf/node_modules/once/node_modules/wrappy/wrappy.js
hooch-0.2.1 jasmine/node_modules/karma-phantomjs-launcher/node_modules/phantomjs/node_modules/fs-extra/node_modules/rimraf/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js