Skip to content

Commit

Permalink
feat: add flush method to output (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 16, 2024
1 parent 66b7da7 commit 4c0d3cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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: [
Expand Down
2 changes: 2 additions & 0 deletions tap-snapshots/test/index.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ exports[`test/index.js TAP output > output keys 1`] = `
Object {
"buffer": "buffer",
"error": "error",
"flush": "flush",
"standard": "standard",
}
`
Expand All @@ -64,6 +65,7 @@ Array [
"standard",
"error",
"buffer",
"flush",
]
`

Expand Down

0 comments on commit 4c0d3cf

Please sign in to comment.