<commit_before>var enrich = function enrich(obj) {
    var _obj = {};
    for (var k in obj) {
        if (obj[k] instanceof Function)
            _obj[k] = function () {
                var method = obj[k];
                return function () {
                    var args = arguments;
                    return this.then(function (res) {
                        return method.apply(this, args);
                    });
                };
            }();
    }
    _obj._enrich = function _enrich(promise) {
        if (!promise._enrich) {
            for (var k in this) promise[k] = this[k];
        }
        return promise;
    };
    return _obj._enrich(Promise.resolve());
};
module.exports = enrich;


var isPromise = function (pendding) {
    return pendding instanceof Promise || padding instanceof Object && padding.then instanceof Function;
};

function concat(threads, f, oks, ohs) {
    var _ok, _oh, removeed;
    var remove = function () {
        var res = !removeed;
        removeed = true;
        return removeed;
    };
    var runable = function (ok, oh) {
        _ok = ok;
        _oh = oh;
    };
    var _promise = new Promise(runable);
    var onpermit = function () {
        remove();
        try {
            var pendding = f.apply(null, arguments);
            if (isPromise(pendding)) {
                pendding.then(_ok);
                pendding.catch(_oh);
            } else {
                _ok(pendding);
            }
        } catch (e) {
            _oh(e);
        }
    };
    var onresolve = function () {
        remove() && _ok.apply(null, arguments);
    };
    var onreject = function () {
        remove() && _oh.apply(null, arguments);
    };
    threads.push(onpermit);
    oks.push(onresolve);
    ohs.push(onreject);
    return _promise;
};

function Promise(executor) {
    var PromiseFulfillReactions = [], //thens
        PromiseRejectReactions = [], //catches
        oked, ohed, resolved;

    function run(threads, args) {
        do {
            var next = threads.shift();
            if (next instanceof Function) {
                next.apply(null, args);
            }
        } while (threads.length);
        PromiseRejectReactions.splice(0);
        PromiseFulfillReactions.splice(0);
    };

    function ResolvingFunctions_resolve() { //ok
        oked = arguments;
        run(PromiseFulfillReactions, oked);
    };

    function ResolvingFunctions_reject(e) { //oh
        ohed = arguments;
        run(PromiseRejectReactions, ohed);
    };

    try {
        executor(ResolvingFunctions_resolve, ResolvingFunctions_reject);
    } catch (e) {
        ResolvingFunctions_reject(e);
    }
    this.then = function (f) {
        var _promise = concat(PromiseFulfillReactions, f, PromiseFulfillReactions, PromiseRejectReactions);
        oked && run(PromiseFulfillReactions, oked);
        ohed && run(PromiseRejectReactions, ohed);
        this._enrich(_promise);
        return _promise;
    };
    this.catch = function (f) {
        var _promise = concat(PromiseRejectReactions, f, PromiseFulfillReactions, PromiseRejectReactions);
        ohed && run(PromiseRejectReactions, ohed);
        oked && run(PromiseFulfillReactions, oked);
        this._enrich(_promise);
        return _promise;
    };
}
Promise.resolve = function () {
    var args = arguments;
    return new Promise(function (ok, oh) {
        ok.apply(null, args);
    });
};<commit_msg>切换为自带的Promise<commit_after>var enrich = function enrich(obj) {
    var _obj = {};
    for (var k in obj) {
        if (obj[k] instanceof Function)
            _obj[k] = function (k) {
                return function () {
                    var method = obj[k];
                    var args = arguments;
                    return this.then(function (res) {
                        return method.apply(this, args);
                    });
                };
            }(k);
    }
    _obj._enrich = function _enrich(promise) {
        if (!promise._enrich) {
            for (var k in this) if (!/^(catch|then)$/.test(k)) promise[k] = this[k];
            var then = promise.then;
            var _catch = promise.catch;
            promise.then = function () {
                return this._enrich(then.apply(this, arguments));
            };
            promise.catch = function () {
                return this.then(_catch.apply(this, arguments));
            }
        }
        return promise;
    };
    return _obj._enrich(Promise.resolve());
};
module.exports = enrich;


// var Promise = new Function(require("fs").readFileSync("coms/zimoli/promise.js").toString()+"\r\nreturn Promise;").apply(global);
{'fraction_non_alphanumeric': 0.12149935372684188, 'fraction_numerical': 0.00043084877208099956, 'mean_word_length': 1.8328248932275777, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1729699', 'n_tokens_mistral': 1371, 'n_tokens_neox': 1331, 'n_words': 299}