<commit_before>/// <reference path="./Helpers.ts"/>

/*
 * Welsh (Promises, but not really)
 * Licensed under the MIT License
 * see LICENSE.md
 *
 * @author <NAME> (kode4food.it)
 */

"use strict";

namespace Welsh {
  import tryCatch = Helpers.tryCatch;
  import getThenFunction = Helpers.getThenFunction;

  export type Resolver = (result?: any) => void;
  export type Rejecter = (reason?: any) => void;
  export type Finalizer = () => void;
  export type Executor = (resolve: Resolver, reject: Rejecter) => void;
  export type NodeCallback = (err: any, result?: any) => void;

  var slice = Array.prototype.slice;

  export enum State {
    fulfilledState = 1,
    rejectedState = 2
  }

  export interface Thenable {
    then(onFulfilled?: Resolver, onRejected?: Rejecter): Thenable;
  }

  export class Common implements Thenable {
    constructor(executor: Executor) {
      // no-op
    }

    then(onFulfilled, onRejected): Common {
      throw new Error("Not implemented");
    }

    catch(onRejected?: Rejecter): Common {
      return this.then(undefined, onRejected);
    }

    finally(onFinally?: Finalizer): Common {
      return this.then(wrappedFulfilled, wrappedRejected);

      function wrappedFulfilled(result) {
        tryCatch(onFinally);
        return result;
      }

      function wrappedRejected(reason) {
        tryCatch(onFinally);
        throw reason;
      }
    }

    toNode(callback: NodeCallback): Common {
      return this.then(wrappedFulfilled, wrappedRejected);

      function wrappedFulfilled(result) {<commit_msg>cleanup<commit_after>/// <reference path="./Helpers.ts"/>

/*
 * Welsh (Promises, but not really)
 * Licensed under the MIT License
 * see LICENSE.md
 *
 * @author <NAME> (kode4food.it)
 */

"use strict";

namespace Welsh {
  import tryCatch = Helpers.tryCatch;
  import getThenFunction = Helpers.getThenFunction;

  export type Resolver = (result?: any) => void;
  export type Rejecter = (reason?: any) => void;
  export type Finalizer = () => void;
  export type Executor = (resolve: Resolver, reject: Rejecter) => void;
  export type NodeCallback = (err: any, result?: any) => void;

  var slice = Array.prototype.slice;

  export enum State {
    fulfilledState = 1,
    rejectedState = 2
  }

  export interface Thenable {
    then(onFulfilled?: Resolver, onRejected?: Rejecter): Thenable;
  }

  export class Common implements Thenable {
    constructor(executor: Executor) {
      // no-op
    }

    then(onFulfilled?: Resolver, onRejected?: Rejecter): Common {
      throw new Error("Not implemented");
    }

    catch(onRejected?: Rejecter): Common {
      return this.then(undefined, onRejected);
    }

    finally(onFinally?: Finalizer): Common {
      return this.then(wrappedFulfilled, wrappedRejected);

      function wrappedFulfilled(result) {
        tryCatch(onFinally);
        return result;
      }

      function wrappedRejected(reason) {
        tryCatch(onFinally);
        throw reason;
      }
    }

    toNode(callback: NodeCallback): Common {
      return this.then(wrappedFulfilled, wrappedRejected);

      function wrappedFulfilled(result) {
{'fraction_non_alphanumeric': 0.1147227533460803, 'fraction_numerical': 0.0019120458891013384, 'mean_word_length': 3.1797603195739015, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, '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': '7168544', 'n_tokens_mistral': 992, 'n_tokens_neox': 945, 'n_words': 248}