Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (isArray(value)) {
return getTypeMapInt('array', buildNativeArray(value));
}
if (isObject(value)) {
if (value instanceof FirestoreDocumentReference) {
return getTypeMapInt('reference', value.path);
}
if (value instanceof FirestoreGeoPoint) {
return getTypeMapInt('geopoint', [value.latitude, value.longitude]);
}
// Handle Date objects are Timestamps as per web sdk
if (isDate(value)) {
const timestamp = FirestoreTimestamp.fromDate(value);
return getTypeMapInt('timestamp', [timestamp.seconds, timestamp.nanoseconds]);
}
if (value instanceof FirestoreTimestamp) {
return getTypeMapInt('timestamp', [value.seconds, value.nanoseconds]);
}
if (value instanceof FirestoreBlob) {
return getTypeMapInt('blob', value.toBase64());
}
if (value instanceof FirestoreFieldValue) {
return getTypeMapInt('fieldvalue', [value._type, value._elements]);
}
static fromDate(date) {
if (!isDate(date)) {
throw new Error(
"firebase.firestore.Timestamp.fromDate(*) 'date' expected a valid Date object.",
);
}
return FirestoreTimestamp.fromMillis(date.getTime());
}