MCPcopy Index your code
hub / github.com/NativeScript/firebase / serializeItems

Function serializeItems

packages/firebase-firestore/index.ios.ts:89–145  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

87}
88
89function serializeItems(value) {
90 if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
91 return value;
92 }
93
94 if (value instanceof Date) {
95 return NSDate.dateWithTimeIntervalSince1970(value.getTime() / 1000);
96 }
97
98 if (value instanceof Timestamp) {
99 return value.native;
100 }
101
102 if (value instanceof GeoPoint) {
103 return value.native;
104 }
105
106 if (value instanceof FieldPath) {
107 return value.native;
108 }
109
110 if (value instanceof FieldValue) {
111 return value.native;
112 }
113
114 if (value instanceof DocumentReference) {
115 return value.native;
116 }
117
118 if (value instanceof CollectionReference) {
119 return value.native;
120 }
121
122 if (value === null) {
123 return NSNull.new();
124 }
125
126 if (Array.isArray(value)) {
127 return value.map((item) => serializeItems(item));
128 }
129
130 if (value && typeof value === 'object') {
131 const keys = Object.keys(value);
132 let dict = {};
133 keys.forEach((key) => {
134 dict[key] = serializeItems(value[key]);
135 });
136
137 return dict;
138 }
139
140 if (value instanceof Bytes) {
141 return value.native;
142 }
143
144 return value;
145}
146

Callers 6

assignKeyValueFunction · 0.70
setMethod · 0.70
whereMethod · 0.70
addMethod · 0.70
setMethod · 0.70
setMethod · 0.70

Calls 1

forEachMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…