Skip to main content

NEW_CAPABILITY_SRC

Constant NEW_CAPABILITY_SRC 

Source
const NEW_CAPABILITY_SRC: &str = "(function(C){\
    var resolve, reject;\
    var executor = (res, rej) => {\
        if (resolve !== undefined || reject !== undefined) {\
            throw new TypeError('Promise capability executor already called');\
        }\
        resolve = res;\
        reject = rej;\
    };\
    var promise = new C(executor);\
    if (typeof resolve !== 'function' || typeof reject !== 'function') {\
        throw new TypeError('Promise resolve or reject function is not callable');\
    }\
    return [promise, resolve, reject];\
})";