Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
return getTypeMapInt('booleanFalse');
}
if (isNumber(value)) {
return getTypeMapInt('number', value);
}
if (isString(value)) {
if (value === '') {
return getTypeMapInt('stringEmpty');
}
return getTypeMapInt('string', value);
}
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]);
function info(text, params = null) {
if (!isString(text)) {
throw new Error(`Invalid text passed to logger. Expected string, but got ${typeof text}`);
}
console.log('\x1b[35m', text);
if (!isArray(params) && !isObject(params) && !isNull(params)) {
throw new Error(
`Invalid params passed to logger. Expected array or object, but got ${typeof params}`,
);
}
if (params) {
console.log('\x1b[94m', JSON.stringify(params, null, 2));
}
resetTerminalColor();
}
suggestReplies(messages) {
if (!isArray(messages)) {
throw new Error(
"firebase.naturalLanguage().suggestReplies(*) 'messages' must be an array value.",
);
}
if (messages.length === 0) {
return Promise.resolve([]);
}
const validated = [];
for (let i = 0; i < messages.length; i++) {
try {
validated.push(validateTextMessage(messages[i]));
} catch (e) {
throw new Error(
exportVal() {
let { value } = this._snapshot;
if (isObject(value) || isArray(value)) {
value = JSON.parse(JSON.stringify(value));
}
return {
'.value': value,
'.priority': this._snapshot.priority,
};
}
requestInfoUpdate(publisherIds) {
if (!isArray(publisherIds)) {
throw new Error(
"firebase.admob.AdsConsent.requestInfoUpdate(*) 'publisherIds' expected an array of string values.",
);
}
if (publisherIds.length === 0) {
throw new Error(
"firebase.admob.AdsConsent.requestInfoUpdate(*) 'publisherIds' list of publisher IDs cannot be empty.",
);
}
for (let i = 0; i < publisherIds.length; i++) {
if (!isString(publisherIds[i])) {
throw new Error(
`firebase.admob.AdsConsent.requestInfoUpdate(*) 'publisherIds[${i}]' expected a string value.`,
);
throw new Error("'options.keywords' expected an array containing string values");
}
for (let i = 0; i < options.keywords.length; i++) {
const keyword = options.keywords[i];
if (!isString(keyword)) {
throw new Error("'options.keywords' expected an array containing string values");
}
}
out.keywords = options.keywords;
}
if (options.testDevices) {
if (!isArray(options.testDevices)) {
throw new Error("'options.testDevices' expected an array containing string values");
}
for (let i = 0; i < options.testDevices.length; i++) {
const device = options.testDevices[i];
if (!isString(device)) {
throw new Error("'options.testDevices' expected an array containing string values");
}
}
out.testDevices = options.testDevices;
}
if (options.contentUrl) {
if (!isString(options.contentUrl)) {
val() {
const { value } = this._snapshot;
if (isObject(value) || isArray(value)) {
return JSON.parse(JSON.stringify(value));
}
return value;
}
}
function validateArrayElements(elements) {
for (let i = 0; i < elements.length; i++) {
const element = elements[i];
if (element instanceof FirestoreFieldValue) {
throw new Error('FieldValue instance cannot be used with other FieldValue methods.');
}
if (isArray(element)) {
throw new Error('Nested arrays are not supported');
}
}
}
cloudDocumentTextRecognizerOptions.enforceCertFingerprintMatch;
}
if (hasOwnProperty(cloudDocumentTextRecognizerOptions, 'apiKeyOverride')) {
if (!isString(cloudDocumentTextRecognizerOptions.apiKeyOverride)) {
throw new Error(
"'cloudDocumentTextRecognizerOptions.apiKeyOverride' expected a string value.",
);
}
out.apiKeyOverride = cloudDocumentTextRecognizerOptions.apiKeyOverride;
}
if (cloudDocumentTextRecognizerOptions.languageHints) {
if (
!isArray(cloudDocumentTextRecognizerOptions.languageHints) ||
!cloudDocumentTextRecognizerOptions.languageHints.length ||
!isString(cloudDocumentTextRecognizerOptions.languageHints[0])
) {
throw new Error(
"'cloudDocumentTextRecognizerOptions.languageHints' must be an non empty array of strings.",
);
}
out.hintedLanguages = cloudDocumentTextRecognizerOptions.languageHints;
}
return out;
}
throw new Error("'options.contentUrl' expected a valid HTTP or HTTPS url.");
}
if (options.contentUrl.length > 512) {
throw new Error("'options.contentUrl' maximum length of a content URL is 512 characters.");
}
out.contentUrl = options.contentUrl;
}
if (options.location) {
const error = new Error(
"'options.location' expected an array value containing a latitude & longitude number value.",
);
if (!isArray(options.location)) {
throw error;
}
const [latitude, longitude] = options.location;
if (!isNumber(latitude) || !isNumber(longitude)) {
throw error;
}
if (latitude < -90 || latitude > 90) {
throw new Error(
`'options.location' latitude value must be a number between -90 and 90, but was: ${latitude}`,
);
}
if (longitude < -180 || longitude > 180) {