<commit_before>import * as google from 'googleapis';
import {config} from './config';
import './promisify';

/**
 * The exception to be thrown when a promise is broken (have exception) and it is already handled.
 * Useful when it comes to response handling as response cannot be sent twice.
 * @example
makePromise
.then(throwRandomError)
.catch(err => {
  handleErr(err);
  throw new BreakSignal();
})
.then(otherStuffs)
.catch(err => {
  if (err instanceof BreakSignal) return
  handleErr2(err);
});
 * @class
 * @extends Error
 */
export class BreakSignam extends Error {}

/**
 * Factory function for creating google.auth.OAuth2 client.
 * Just because copying code is too stubid.
 *
 * @static
 * @returns {google.auth.OAuth2} - New OAuth2 object that have client ID,
 * secret and redirect url set.
 */
export function oauth2clientFactory() {
  return new google.auth.OAuth2(config.clientID, config.clientSecret, config.redirectUrl);
}

/**
 * Error catcher for validate.js.
 * Validate.js throws an array as error in flat mode. This handler will join the array
 * with ';\n' and throw an error object.
 *
 * @param {Array} err - Error array thrown by validate.js in flat mode.
 * @throws {Error} - Error object with error accepted.
 */
export function validateErrorHandle(err) {
  throw new Error(err.join(';\n'));<commit_msg>FIX: Minor typos in utils<commit_after>import * as google from 'googleapis';
import {config} from './config';
import './promisify';

/**
 * The exception to be thrown when a promise is broken (have exception) and it is already handled.
 * Useful when it comes to response handling as response cannot be sent twice.
 * @example
makePromise
.then(throwRandomError)
.catch(err => {
  handleErr(err);
  throw new BreakSignal();
})
.then(otherStuffs)
.catch(err => {
  if (err instanceof BreakSignal) return
  handleErr2(err);
});
 * @class
 * @extends Error
 */
export class BreakSignal extends Error {}

/**
 * Factory function for creating google.auth.OAuth2 client.
 * Just because copying code is too stupid.
 *
 * @static
 * @returns {google.auth.OAuth2} - New OAuth2 object that have client ID,
 * secret and redirect url set.
 */
export function oauth2clientFactory() {
  return new google.auth.OAuth2(config.clientID, config.clientSecret, config.redirectUrl);
}

/**
 * Error catcher for validate.js.
 * Validate.js throws an array as error in flat mode. This handler will join the array
 * with ';\n' and throw an error object.
 *
 * @param {Array} err - Error array thrown by validate.js in flat mode.
 * @throws {Error} - Error object with error accepted.
 */
export function validateErrorHandle(err) {
  throw new Error(err.join(';\n'));
{'fraction_non_alphanumeric': 0.11389096340552651, 'fraction_numerical': 0.004480955937266617, 'mean_word_length': 4.026266416510319, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1161184', 'n_tokens_mistral': 775, 'n_tokens_neox': 773, 'n_words': 307}