<commit_before>import Firebase from 'firebase';
import config from 'config';

export function firebaseInit() {
  // Authenticate with Firebase
  const ref = new Firebase(config.get('firebase.path'));
  ref.authWithCustomToken(config.get('firebase.apiKey'), (error) => {
    if (error) {
      console.error('Terminating startup due to bad Firebase ref');
      process.exit(1);
    }

    // Conveniently access the root ref
    Firebase.root = ref;
  });
}<commit_msg>Add Firebase once promise wrapper to facilitate async/await<commit_after>import Firebase from 'firebase';
import config from 'config';

export function firebaseInit() {
  // Authenticate with Firebase
  const ref = new Firebase(config.get('firebase.path'));
  ref.authWithCustomToken(config.get('firebase.apiKey'), (error) => {
    if (error) {
      console.error('Terminating startup due to bad Firebase ref');
      process.exit(1);
    }

    // Conveniently access the root ref
    Firebase.root = ref;
  });
}

export function once(type, child) {
  return new Promise((resolve, reject) => {
    Firebase.root.child(child).once(type, (snapshot) => {
      resolve(snapshot.val());
    }, (err) => {
      reject(err);
    });
  });
}
{'fraction_non_alphanumeric': 0.140016570008285, 'fraction_numerical': 0.0016570008285004142, 'mean_word_length': 3.646153846153846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, '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': '474685', 'n_tokens_mistral': 370, 'n_tokens_neox': 369, 'n_words': 94}