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

Function clone

lib/index.es.js:43–85  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

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