mirror of
https://github.com/tenrok/axios.git
synced 2026-06-23 20:40:40 +03:00
feat: compatibility with frozen prototypes (#6265)
* fix(types): some JSDoc param defs * fix: compatibility with HardenedJS * Update lib/utils.js Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Jay <jasonsaayman@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
+23
-6
@@ -252,10 +252,11 @@ const trim = (str) => str.trim ?
|
|||||||
* If 'obj' is an Object callback will be called passing
|
* If 'obj' is an Object callback will be called passing
|
||||||
* the value, key, and complete object for each property.
|
* the value, key, and complete object for each property.
|
||||||
*
|
*
|
||||||
* @param {Object|Array} obj The object to iterate
|
* @param {Object|Array<unknown>} obj The object to iterate
|
||||||
* @param {Function} fn The callback to invoke for each item
|
* @param {Function} fn The callback to invoke for each item
|
||||||
*
|
*
|
||||||
* @param {Boolean} [allOwnKeys = false]
|
* @param {Object} [options]
|
||||||
|
* @param {Boolean} [options.allOwnKeys = false]
|
||||||
* @returns {any}
|
* @returns {any}
|
||||||
*/
|
*/
|
||||||
function forEach(obj, fn, {allOwnKeys = false} = {}) {
|
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} b The object to copy properties from
|
||||||
* @param {Object} thisArg The object to bind function to
|
* @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
|
* @returns {Object} The resulting value of object a
|
||||||
*/
|
*/
|
||||||
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
const extend = (a, b, thisArg, {allOwnKeys}= {}) => {
|
||||||
forEach(b, (val, key) => {
|
forEach(b, (val, key) => {
|
||||||
if (thisArg && isFunction(val)) {
|
if (thisArg && isFunction(val)) {
|
||||||
a[key] = bind(val, thisArg);
|
Object.defineProperty(a, key, {
|
||||||
|
value: bind(val, thisArg),
|
||||||
|
writable: true,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
a[key] = val;
|
Object.defineProperty(a, key, {
|
||||||
|
value: val,
|
||||||
|
writable: true,
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, {allOwnKeys});
|
}, {allOwnKeys});
|
||||||
return a;
|
return a;
|
||||||
@@ -408,7 +420,12 @@ const stripBOM = (content) => {
|
|||||||
*/
|
*/
|
||||||
const inherits = (constructor, superConstructor, props, descriptors) => {
|
const inherits = (constructor, superConstructor, props, descriptors) => {
|
||||||
constructor.prototype = Object.create(superConstructor.prototype, 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', {
|
Object.defineProperty(constructor, 'super', {
|
||||||
value: superConstructor.prototype
|
value: superConstructor.prototype
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user