MCPcopy
hub / github.com/strongloop/loopback / cloneDeepJson

Function cloneDeepJson

lib/builtin-models.js:86–98  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

84// the cloning algorithm can stay much simpler than a general-purpose
85// "cloneDeep" e.g. from lodash.
86function cloneDeepJson(obj) {
87 const result = Array.isArray(obj) ? [] : {};
88 assert.equal(Object.getPrototypeOf(result), Object.getPrototypeOf(obj));
89 for (const key in obj) {
90 const value = obj[key];
91 if (typeof value === 'object') {
92 result[key] = cloneDeepJson(value);
93 } else {
94 result[key] = value;
95 }
96 }
97 return result;
98}

Callers 1

createModelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…