MCPcopy Create free account
hub / github.com/nodejs/node / formatWithOptions

Function formatWithOptions

deps/npm/lib/utils/format.js:44–54  ·  view source on GitHub ↗
({ prefix: prefixes = [], eol = '\n', redact = true, ...options }, ...args)

Source from the content-addressed store, hash-verified

42}
43
44const formatWithOptions = ({ prefix: prefixes = [], eol = '\n', redact = true, ...options }, ...args) => {
45 const prefix = prefixes.filter(p => p != null).join(' ')
46 let formatted = STRIP_C01(baseFormatWithOptions(options, ...args))
47 if (redact) {
48 formatted = redactLog(formatted)
49 }
50 // Splitting could be changed to only `\n` once we are sure we only emit unix newlines.
51 // The eol param to this function will put the correct newlines in place for the returned string.
52 const lines = formatted.split(/\r?\n/)
53 return lines.reduce((acc, l) => `${acc}${prefix}${prefix && l ? ' ' : ''}${l}${eol}`, '')
54}
55
56module.exports = { formatWithOptions }

Callers 2

#writeMethod · 0.70
#formatLogItemMethod · 0.70

Calls 5

STRIP_C01Function · 0.85
reduceMethod · 0.80
filterMethod · 0.65
joinMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected