<commit_before>"use strict";
function isPromise(obj) {
    return obj && typeof obj.then === 'function';
}

function shouldFulfilled(promise) {
    if (!isPromise(promise)) {
        throw new Error("This is not promise object: " + promise);
    }
    return {
        "then": function (fn) {
            return promise.then(function (value) {
                    fn.call(promise, value);
                }, function (reason) {
                    return new promise.constructor(function (resolve, reject) {
                        reject(reason);
                    });
                }
            );
        },
        "catch": function () {
            // == Promise.reject
            return new promise.constructor(function (resolve, reject) {
                reject(new Error("Expected promise to be fulfilled so you should use `shouldFulfilled(promise).then`"));
            });
        }
    };
}
function shouldRejected(promise) {
    if (!isPromise(promise)) {
        throw new Error("This is not promise object: " + promise);
    }
    return {
        "then": function () {
            return new promise.constructor(function (resolve, reject) {
                reject(new Error("Expected promise to be rejected so you should use `shouldRejected(promise).catch`"));
            });
        },
        "catch": function (fn) {
            return promise.then(function () {
                    return new promise.constructor(function (resolve, reject) {
                        reject(new Error("Expected promise to be rejected but it was fulfilled"));
                    });
                }, function (reason) {
                    fn.call(promise, reason);
                }
            );
        }
    };
}
module.exports.shouldFulfilled = shouldFulfilled;
module.exports.shouldRejected = shouldRejected;<commit_msg>docs( promise-test-helper ) : add comment to then/catch<commit_after>"use strict";
function isPromise(obj) {
    return obj && typeof obj.then === 'function';
}

function shouldFulfilled(promise) {
    if (!isPromise(promise)) {
        throw new Error("This is not promise object: " + promise);
    }
    return {
        // when promise is rejected, throw error
        "then": function (fn) {
            return promise.then(function (value) {
                    fn.call(promise, value);
                }, function (reason) {
                    return new promise.constructor(function (resolve, reject) {
                        reject(reason);
                    });
                }
            );
        },
        "catch": function () {
            // == Promise.reject
            return new promise.constructor(function (resolve, reject) {
                reject(new Error("Expected promise to be fulfilled so you should use `shouldFulfilled(promise).then`"));
            });
        }
    };
}
function shouldRejected(promise) {
    if (!isPromise(promise)) {
        throw new Error("This is not promise object: " + promise);
    }
    return {
        "then": function () {
            return new promise.constructor(function (resolve, reject) {
                reject(new Error("Expected promise to be rejected so you should use `shouldRejected(promise).catch`"));
            });
        },
        // when promise is fulfilled, throw error
        "catch": function (fn) {
            return promise.then(function () {
                    return new promise.constructor(function (resolve, reject) {
                        reject(new Error("Expected promise to be rejected but it was fulfilled"));
                    });
                }, function (reason) {
                    fn.call(promise, reason);
                }
            );
        }
    };
}
module.exports.shouldFulfilled = shouldFulfilled;
module.exports.shouldRejected = shouldRejected;
{'fraction_non_alphanumeric': 0.11323722149410223, 'fraction_numerical': 0.0, 'mean_word_length': 1.735483870967742, 'pattern_counts': {'":': 8, '<': 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': '2236220', 'n_tokens_mistral': 954, 'n_tokens_neox': 911, 'n_words': 248}