Skip to content

Commit

Permalink
fix: compatibility with HardenedJS
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Apr 8, 2024
1 parent 751133e commit 696d13e
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/utils.js
Expand Up @@ -342,9 +342,9 @@ function merge(/* obj1, obj2, obj3, ... */) {
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)});
} else {
a[key] = val;
Object.defineProperty(a, key, {value: val});
}
}, {allOwnKeys});
return a;
Expand Down Expand Up @@ -375,7 +375,9 @@ 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
});
Object.defineProperty(constructor, 'super', {
value: superConstructor.prototype
});
Expand Down Expand Up @@ -537,12 +539,14 @@ const isRegExp = kindOfTest('RegExp');

const reduceDescriptors = (obj, reducer) => {
const descriptors = Object.getOwnPropertyDescriptors(obj);
const reducedDescriptors = {};
let reducedDescriptors = {};

forEach(descriptors, (descriptor, name) => {
let ret;
if ((ret = reducer(descriptor, name, obj)) !== false) {
reducedDescriptors[name] = ret || descriptor;
reducedDescriptors = {...reducedDescriptors,
[name]: ret || descriptor
};
}
});

Expand Down

0 comments on commit 696d13e

Please sign in to comment.