mpackdb
All repositories: gitoria
1.0 KB
export function isObject(item) {return (item && item !== null && typeof item === 'object' && !Array.isArray(item));}// with recursion detectionexport function assignDeep(target, ...sources) {const seen = new WeakSet(); // Use WeakSet to store processed objectsconst mergeInternal = (target, source) => {if (!isObject(target) || !isObject(source)) {return;}// Check if the object has been processed beforeif (seen.has(source)) {return;}seen.add(source); // Mark the object as processedfor (const key in source) {if (isObject(source[key]) && target[key]) {mergeInternal(target[key], source[key]);} else {try {target[key] = source[key];} catch (e) {// Handle the case where a non-writable property is tried to be set}}}};for (const source of sources) {mergeInternal(target, source);}return target;}export class Model {constructor(data = {}, merge = true) {if (merge) {assignDeep(this, data);} else {Object.assign(this, data);}}}
Branches
- mastermain branch
Latest commits
- d01dda02add index hints, intersection, boundingBox; remove findByIndexcaramboleyo
- b8ffc1a0release 1.0.5caramboleyo
- d47876a1reimplemented lost features like indexed find and more testscaramboleyo
- 7f08da9afixed insert ignoring model definitioncaramboleyo
- 705774a9added flush before findcaramboleyo
- b4db6391initial commitcaramboleyo