Sha256: 3ad88085993b790a43c1b44f20f4957f3f10b950f91f3c2ddc6b0691447e8df8

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

/*!
 * merge-descriptors
 * Copyright(c) 2014 Jonathan Ong
 * MIT Licensed
 */

/**
 * Module exports.
 * @public
 */

module.exports = merge

/**
 * Module variables.
 * @private
 */

var hasOwnProperty = Object.prototype.hasOwnProperty

/**
 * Merge the property descriptors of `src` into `dest`
 *
 * @param {object} dest Object to add descriptors to
 * @param {object} src Object to clone descriptors from
 * @param {boolean} [redefine=true] Redefine `dest` properties with `src` properties
 * @returns {object} Reference to dest
 * @public
 */

function merge(dest, src, redefine) {
  if (!dest) {
    throw new TypeError('argument dest is required')
  }

  if (!src) {
    throw new TypeError('argument src is required')
  }

  if (redefine === undefined) {
    // Default to true
    redefine = true
  }

  Object.getOwnPropertyNames(src).forEach(function forEachOwnPropertyName(name) {
    if (!redefine && hasOwnProperty.call(dest, name)) {
      // Skip desriptor
      return
    }

    // Copy descriptor
    var descriptor = Object.getOwnPropertyDescriptor(src, name)
    Object.defineProperty(dest, name, descriptor)
  })

  return dest
}

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
webpack_rails-2.0.1 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-2.0.0 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.3.1 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.3.0 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.2.2 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.2.1 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.2.0 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.1.1 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.1.0 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.0.1 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
webpack_rails-1.0.0 lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack-dev-server/node_modules/express/node_modules/merge-descriptors/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack-dev-server/node_modules/express/node_modules/merge-descriptors/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack-dev-server/node_modules/express/node_modules/merge-descriptors/index.js