r19
Version:
Simple remote procedure calls in TypeScript
29 lines (28 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const isPlainObject = (value) => {
if (typeof value !== "object" || value === null) {
return false;
}
const prototype = Object.getPrototypeOf(value);
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
};
const replaceLeaves = async (input, replacer) => {
if (Array.isArray(input)) {
const preparedProcedureArgs = [];
for (let i = 0; i < input.length; i++) {
preparedProcedureArgs[i] = await replaceLeaves(input[i], replacer);
}
return preparedProcedureArgs;
}
if (isPlainObject(input)) {
const preparedProcedureArgs = {};
for (const key in input) {
preparedProcedureArgs[key] = await replaceLeaves(input[key], replacer);
}
return preparedProcedureArgs;
}
return await replacer(input);
};
exports.replaceLeaves = replaceLeaves;
//# sourceMappingURL=replaceLeaves.cjs.map