<commit_before>import * as firebase from "../firebase";
import { firebaseUtils } from '../utils';
import { HttpsCallable } from './functions';

let functions: FIRFunctions;

function getFunctions(region?: firebase.functions.SupportedRegions): FIRFunctions {
  if (!functions) {
    functions = region ? FIRFunctions.functionsForRegion(region) : FIRFunctions.functions();
  }
  return functions;
}

export function httpsCallable<I = {}, O = {}>(functionName: string, region?: firebase.functions.SupportedRegions): HttpsCallable<I, O> {

  const functions = getFunctions();

  return (data: I) => new Promise((resolve, reject) => {

    const callable = functions.HTTPSCallableWithName(functionName);

    const handleCompletion = (result: FIRHTTPSCallableResult, err: NSError) => {
      if (err) {
        reject(err.localizedDescription);
        return;
      }<commit_msg>getFunctions should have had the region as its argument which was not there, and subsiquently caused problem accessing functions on iOS if they are in a different region than us-central.<commit_after>import * as firebase from "../firebase";
import { firebaseUtils } from '../utils';
import { HttpsCallable } from './functions';

let functions: FIRFunctions;

function getFunctions(region?: firebase.functions.SupportedRegions): FIRFunctions {
  if (!functions) {
    functions = region ? FIRFunctions.functionsForRegion(region) : FIRFunctions.functions();
  }
  return functions;
}

export function httpsCallable<I = {}, O = {}>(functionName: string, region?: firebase.functions.SupportedRegions): HttpsCallable<I, O> {
  const functions = getFunctions(region);

  return (data: I) => new Promise((resolve, reject) => {

    const callable = functions.HTTPSCallableWithName(functionName);

    const handleCompletion = (result: FIRHTTPSCallableResult, err: NSError) => {
      if (err) {
        reject(err.localizedDescription);
        return;
      }
{'fraction_non_alphanumeric': 0.1187759336099585, 'fraction_numerical': 0.0, 'mean_word_length': 4.5590778097982705, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3688826', 'n_tokens_mistral': 543, 'n_tokens_neox': 520, 'n_words': 149}