diff --git a/README.md b/README.md index f4b174e..9d1d1a9 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ const { log, output, input, time } = require('proc-log') This is for buffered output. Consumers will typically buffer this until they are ready to display. +* `output.flush(...args)` calls `process.emit('output', 'flush', ...args)` + + This is to indicate that the output buffer should be flushed. + * `output.LEVELS` an array of strings of all output method names #### log diff --git a/lib/index.js b/lib/index.js index 5e8031d..86d9086 100644 --- a/lib/index.js +++ b/lib/index.js @@ -6,11 +6,13 @@ module.exports = { 'standard', 'error', 'buffer', + 'flush', ], KEYS: { standard: 'standard', error: 'error', buffer: 'buffer', + flush: 'flush', }, standard: function (...args) { return process.emit('output', 'standard', ...args) @@ -21,6 +23,9 @@ module.exports = { buffer: function (...args) { return process.emit('output', 'buffer', ...args) }, + flush: function (...args) { + return process.emit('output', 'flush', ...args) + }, }, log: { LEVELS: [ diff --git a/tap-snapshots/test/index.js.test.cjs b/tap-snapshots/test/index.js.test.cjs index a0f06a4..34fdc70 100644 --- a/tap-snapshots/test/index.js.test.cjs +++ b/tap-snapshots/test/index.js.test.cjs @@ -55,6 +55,7 @@ exports[`test/index.js TAP output > output keys 1`] = ` Object { "buffer": "buffer", "error": "error", + "flush": "flush", "standard": "standard", } ` @@ -64,6 +65,7 @@ Array [ "standard", "error", "buffer", + "flush", ] `