summaryrefslogtreecommitdiffstats
path: root/middleware/node_modules/merge-descriptors/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/node_modules/merge-descriptors/index.js')
-rw-r--r--middleware/node_modules/merge-descriptors/index.js60
1 files changed, 60 insertions, 0 deletions
diff --git a/middleware/node_modules/merge-descriptors/index.js b/middleware/node_modules/merge-descriptors/index.js
new file mode 100644
index 0000000..573b132
--- /dev/null
+++ b/middleware/node_modules/merge-descriptors/index.js
@@ -0,0 +1,60 @@
+/*!
+ * merge-descriptors
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * 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
+}