UNPKG

@tanstack/start-client-core

Version:

Modern and scalable routing for React applications

30 lines (29 loc) 964 B
//#region src/safeObjectMerge.ts function isSafeKey(key) { return key !== "__proto__" && key !== "constructor" && key !== "prototype"; } /** * Merge target and source into a new null-proto object, filtering dangerous keys. */ function safeObjectMerge(target, source) { const result = Object.create(null); if (target) { for (const key of Object.keys(target)) if (isSafeKey(key)) result[key] = target[key]; } if (source && typeof source === "object") { for (const key of Object.keys(source)) if (isSafeKey(key)) result[key] = source[key]; } return result; } /** * Create a null-prototype object, optionally copying from source. */ function createNullProtoObject(source) { if (!source) return Object.create(null); const obj = Object.create(null); for (const key of Object.keys(source)) if (isSafeKey(key)) obj[key] = source[key]; return obj; } //#endregion export { createNullProtoObject, safeObjectMerge }; //# sourceMappingURL=safeObjectMerge.js.map