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

Function clone

lib/index.js:48–90  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

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

Callers 13

toPromiseFunction · 0.70
constructorMethod · 0.70
doChangesMethod · 0.70
_setupMethod · 0.70
_setupMethod · 0.70
massageSelectorFunction · 0.70
LevelPouchFunction · 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…