fexios
Version:
Fetch based HTTP client with similar API to axios for browser and Node.js
49 lines (44 loc) • 1.55 kB
JavaScript
;
const isPlainObject = require('../shared/fexios.C6EYiGQl.cjs');
const CallableInstanceImpl = function(property) {
const proto = this.constructor.prototype;
const func = Reflect.get(proto, property, proto);
function apply(...args) {
return Reflect.apply(func, apply, args);
}
Reflect.setPrototypeOf(apply, proto);
for (const key of Reflect.ownKeys(func)) {
const desc = Reflect.getOwnPropertyDescriptor(func, key);
if (desc) Reflect.defineProperty(apply, key, desc);
}
return apply;
};
CallableInstanceImpl.prototype = Object.create(Function.prototype);
const CallableInstance = CallableInstanceImpl;
function deepMerge(obj, ...incomes) {
const result = isPlainObject.clone(obj || {});
for (const inc of incomes) {
if (inc == null) continue;
for (const key of Reflect.ownKeys(inc)) {
const nextVal = inc[key];
if (typeof nextVal === "undefined") continue;
if (nextVal === null) {
delete result[key];
continue;
}
const prevVal = result[key];
if (isPlainObject.isPlainObject(prevVal) && isPlainObject.isPlainObject(nextVal)) {
result[key] = deepMerge(prevVal, nextVal);
} else {
result[key] = isPlainObject.clone(nextVal);
}
}
}
return result;
}
exports.checkIsPlainObject = isPlainObject.isPlainObject;
exports.clone = isPlainObject.clone;
exports.isPlainObject = isPlainObject.isPlainObject;
exports.CallableInstance = CallableInstance;
exports.deepMerge = deepMerge;
//# sourceMappingURL=index.cjs.map