Skip to main content

FINALLY_HELPER_SRC

Constant FINALLY_HELPER_SRC 

Source
const FINALLY_HELPER_SRC: &str = "(function(p, onFinally){\
    var C = p.constructor;\
    if (C === undefined) { C = Promise; }\
    else if ((typeof C !== 'object' && typeof C !== 'function') || C === null) {\
        throw new TypeError('Promise constructor is not an object');\
    } else {\
        var S = C[Symbol.species];\
        if (S !== undefined && S !== null) C = S;\
        if (typeof C !== 'function') throw new TypeError('Promise species is not a constructor');\
    }\
    if (typeof onFinally !== 'function') {\
        return p.then(onFinally, onFinally);\
    }\
    return p.then(\
        (value) => {\
            var pr = Promise.resolve.call(C, onFinally());\
            return pr.then(() => value);\
        },\
        (reason) => {\
            var pr = Promise.resolve.call(C, onFinally());\
            return pr.then(() => { throw reason; });\
        }\
    );\
})";