diff --git a/lib/utils.js b/lib/utils.js index ade8309..ed08161 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -252,10 +252,11 @@ const trim = (str) => str.trim ? * If 'obj' is an Object callback will be called passing * the value, key, and complete object for each property. * - * @param {Object|Array} obj The object to iterate + * @param {Object|Array} obj The object to iterate * @param {Function} fn The callback to invoke for each item * - * @param {Boolean} [allOwnKeys = false] + * @param {Object} [options] + * @param {Boolean} [options.allOwnKeys = false] * @returns {any} */ function forEach(obj, fn, {allOwnKeys = false} = {}) { @@ -369,15 +370,26 @@ function merge(/* obj1, obj2, obj3, ... */) { * @param {Object} b The object to copy properties from * @param {Object} thisArg The object to bind function to * - * @param {Boolean} [allOwnKeys] + * @param {Object} [options] + * @param {Boolean} [options.allOwnKeys] * @returns {Object} The resulting value of object a */ const extend = (a, b, thisArg, {allOwnKeys}= {}) => { forEach(b, (val, key) => { if (thisArg && isFunction(val)) { - a[key] = bind(val, thisArg); + Object.defineProperty(a, key, { + value: bind(val, thisArg), + writable: true, + enumerable: true, + configurable: true + }); } else { - a[key] = val; + Object.defineProperty(a, key, { + value: val, + writable: true, + enumerable: true, + configurable: true + }); } }, {allOwnKeys}); return a; @@ -408,7 +420,12 @@ const stripBOM = (content) => { */ const inherits = (constructor, superConstructor, props, descriptors) => { constructor.prototype = Object.create(superConstructor.prototype, descriptors); - constructor.prototype.constructor = constructor; + Object.defineProperty(constructor.prototype, 'constructor', { + value: constructor, + writable: true, + enumerable: false, + configurable: true + }); Object.defineProperty(constructor, 'super', { value: superConstructor.prototype });