How to use the @react-native-firebase/app/lib/common.isArray function in @react-native-firebase/app

To help you get started, we’ve selected a few @react-native-firebase/app examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github invertase / react-native-firebase / packages / firestore / lib / utils / serialize.js View on Github external
}
    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]);
github invertase / react-native-firebase / packages / app / lib / utils / logger.js View on Github external
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();
}
github invertase / react-native-firebase / packages / ml-natural-language / lib / index.js View on Github external
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(
github invertase / react-native-firebase / packages / database / lib / DatabaseDataSnapshot.js View on Github external
exportVal() {
    let { value } = this._snapshot;

    if (isObject(value) || isArray(value)) {
      value = JSON.parse(JSON.stringify(value));
    }

    return {
      '.value': value,
      '.priority': this._snapshot.priority,
    };
  }
github invertase / react-native-firebase / packages / admob / lib / AdsConsent.js View on Github external
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.`,
        );
github invertase / react-native-firebase / packages / admob / lib / validateAdRequestOptions.js View on Github external
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)) {
github invertase / react-native-firebase / packages / database / lib / DatabaseDataSnapshot.js View on Github external
val() {
    const { value } = this._snapshot;

    if (isObject(value) || isArray(value)) {
      return JSON.parse(JSON.stringify(value));
    }

    return value;
  }
}
github invertase / react-native-firebase / packages / firestore / lib / FirestoreFieldValue.js View on Github external
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');
    }
  }
}
github invertase / react-native-firebase / packages / ml-vision / lib / visionCloudDocumentTextRecognizerOptions.js View on Github external
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;
}
github invertase / react-native-firebase / packages / admob / lib / validateAdRequestOptions.js View on Github external
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) {

@react-native-firebase/app

A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto

Apache-2.0
Latest version published 1 day ago

Package Health Score

98 / 100
Full package analysis