UNPKG

for-emit-of

Version:

Turn Node.js Events into Async Iterables

52 lines (51 loc) 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.debugIteratorReturn = exports.debugKeepAliveEnding = exports.debugKeepAlive = exports.debugYielding = exports.debugYieldLimit = exports.debugRaceStart = exports.debugRaceEnd = void 0; function debugRaceEnd(options, winner) { if (options.debug) { console.log(`Finished response racing. Winner: ${String(winner)}`); } } exports.debugRaceEnd = debugRaceEnd; function debugRaceStart(options) { if (options.debug) { console.log("No more results to yield but emitter still active. Starting timeout race"); } } exports.debugRaceStart = debugRaceStart; function debugYieldLimit(options) { if (options.debug) { console.log("Yielding limit reached! Stopping iterator"); } } exports.debugYieldLimit = debugYieldLimit; function debugYielding(options, events) { if (options.debug) { console.log(`Results to yield: ${events.length}`); } } exports.debugYielding = debugYielding; function debugKeepAlive(options, countKeepAlive, start) { if (options.debug) { countKeepAlive++; const current = process.hrtime(start); const seconds = current[0] + current[1] / 1e9; console.log(`${countKeepAlive} keepalive cycles, ${seconds} secs, ${(countKeepAlive / seconds).toFixed(2)} cycles per second`); } return countKeepAlive; } exports.debugKeepAlive = debugKeepAlive; function debugKeepAliveEnding(options, countKeepAlive, start) { if (options.debug) { const current = process.hrtime(start); const seconds = current[0] + current[1] / 1e9; console.log(`Finishing keep alive control: ${countKeepAlive} keepalive cycles, ${seconds} secs, ${(countKeepAlive / seconds).toFixed(2)} cycles per second`); } } exports.debugKeepAliveEnding = debugKeepAliveEnding; function debugIteratorReturn(options) { if (options.debug) { console.log("Iterator return called and process finalized"); } } exports.debugIteratorReturn = debugIteratorReturn;