Sha256: b9d3770080970a3e2923463bd5f5dc4e5f15493cc4d4d762eb60b7cd3eaeca14

Contents?: true

Size: 1.07 KB

Versions: 20

Compression:

Stored size: 1.07 KB

Contents

"use strict";
function noop() { }
function once(emitter, name) {
    const o = once.spread(emitter, name);
    const r = o.then((args) => args[0]);
    r.cancel = o.cancel;
    return r;
}
(function (once) {
    function spread(emitter, name) {
        let c = null;
        const p = new Promise((resolve, reject) => {
            function cancel() {
                emitter.removeListener(name, onEvent);
                emitter.removeListener('error', onError);
                p.cancel = noop;
            }
            function onEvent(...args) {
                cancel();
                resolve(args);
            }
            function onError(err) {
                cancel();
                reject(err);
            }
            c = cancel;
            emitter.on(name, onEvent);
            emitter.on('error', onError);
        });
        if (!c) {
            throw new TypeError('Could not get `cancel()` function');
        }
        p.cancel = c;
        return p;
    }
    once.spread = spread;
})(once || (once = {}));
module.exports = once;
//# sourceMappingURL=index.js.map

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.72.1 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.72.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.71.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.70.2 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.70.1 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.70.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.69.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.68.2 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.68.1 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.68.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.67.1 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.67.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.66.2 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.66.1 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.66.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.65.1 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.65.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.64.0 ./node_modules/@tootallnate/once/dist/index.js
appmap-0.63.0 ./node_modules/@tootallnate/once/dist/index.js