MCPcopy Index your code
hub / github.com/apache/pouchdb / clone

Function clone

lib/index-browser.js:44–86  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

42}
43
44function clone(object) {
45 var newObject;
46 var i;
47 var len;
48
49 if (!object || typeof object !== 'object') {
50 return object;
51 }
52
53 if (Array.isArray(object)) {
54 newObject = [];
55 for (i = 0, len = object.length; i < len; i++) {
56 newObject[i] = clone(object[i]);
57 }
58 return newObject;
59 }
60
61 // special case: to avoid inconsistencies between IndexedDB
62 // and other backends, we automatically stringify Dates
63 if (object instanceof Date && isFinite(object)) {
64 return object.toISOString();
65 }
66
67 if (isBinaryObject(object)) {
68 return cloneBinaryObject(object);
69 }
70
71 if (!isPlainObject(object)) {
72 return object; // don't clone objects like Workers
73 }
74
75 newObject = {};
76 for (i in object) {
77 /* istanbul ignore else */
78 if (Object.prototype.hasOwnProperty.call(object, i)) {
79 var value = clone(object[i]);
80 if (typeof value !== 'undefined') {
81 newObject[i] = value;
82 }
83 }
84 }
85 return newObject;
86}
87
88function once(fun) {
89 var called = false;

Callers 13

toPromiseFunction · 0.70
constructorMethod · 0.70
doChangesMethod · 0.70
_setupMethod · 0.70
_setupMethod · 0.70
massageSelectorFunction · 0.70
changesFunction · 0.70
HttpPouchFunction · 0.70
getDocsFunction · 0.70
writeDocsFunction · 0.70
finishBatchFunction · 0.70
replicateWrapperFunction · 0.70

Calls 3

isBinaryObjectFunction · 0.70
cloneBinaryObjectFunction · 0.70
isPlainObjectFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…