<commit_before>'use strict';

module.exports = function createPromiseUtils(Promise) {

    var promises = {
        Promise: Promise
    };

    /**
     * This method creates a new promise, initially in the pending state, and provides references to the resolving
     * functions that can be used to change its state. It will not return until the given executor function has
     * completed. The resolving functions can be used at any time, before or after the executor has completed, to
     * control the final state of the promise. If the executor throws an exception, its value will be passed to the
     * <i>reject</i> resolving function.
     *
     * @param executor This function is invoked immediately with the resolving functions as its two arguments:
     * <i>executor(resolve, reject)</i>.
     *
     * @returns {Promise} a promise
     */
    promises.newPromise = function (executor) {
        if (promises.Promise) {
            return new promises.Promise(executor);
        }
        throw new Error('No promise implementation available! Please plug nightshift-bluebird or create a NightShift plugin for your favorite promise implementation...');
    };

    /**
     * This method creates a deferred object that exposes the associated Promise instance as well as the resolving
     * functions that can be used to change its state. It is inspired by Kris Kowal's Q.
     *
     * @returns a deferred object
     */
    promises.defer = function () {
        var deferred = {};
        deferred.promise = promises.newPromise(function (resolve, reject) {
            deferred.resolve = resolve;
            deferred.reject = reject;
        });
        return deferred;
    };

    return promises;
};<commit_msg>Working on documentation of new features<commit_after>'use strict';

module.exports = function createPromiseUtils(Promise) {

    var promises = {
        Promise: Promise
    };

    /**
     * This method creates a new promise, initially in the pending state, and provides references to the resolving
     * functions that can be used to change its state. It will not return until the given executor function has
     * completed. The resolving functions can be used at any time, before or after the executor has completed, to
     * control the final state of the promise. If the executor throws an exception, its value will be passed to the
     * <i>reject</i> resolving function.
     *
     * @param executor This function is invoked immediately with the resolving functions as its two arguments:
     * <i>executor(resolve, reject)</i>.
     *
     * @returns {Promise} a promise
     */
    promises.newPromise = function (executor) {
        if (promises.Promise) {
            return new promises.Promise(executor);
        }
        throw new Error('No promise implementation available! Please plug nightshift-bluebird or create a NightShift plugin for your favorite promise implementation...');
    };

    /**
     * This method creates a deferred object that exposes the associated promise as well as the resolving functions that
     * can be used to change its state. It is inspired by <NAME> Q.
     *
     * @returns a deferred object
     */
    promises.defer = function () {
        var deferred = {};
        deferred.promise = promises.newPromise(function (resolve, reject) {
            deferred.resolve = resolve;
            deferred.reject = reject;
        });
        return deferred;
    };

    return promises;
};
{'fraction_non_alphanumeric': 0.075, 'fraction_numerical': 0.0, 'mean_word_length': 2.6642105263157894, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '2092622', 'n_tokens_mistral': 854, 'n_tokens_neox': 826, 'n_words': 377}