Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import type { TransformableInfo, TransformFunction } from '../type'
import { MESSAGE } from '../../triple-beam'
type TemplateFn = (info: TransformableInfo) => any
class Printf {
template: TemplateFn
constructor(templateFn: TemplateFn) {
this.template = templateFn
}
transform: TransformFunction = (info) => {
info[MESSAGE] = this.template(info)
return info
}
}
/*
* function printf (templateFn)
* Returns a new instance of the printf Format that creates an
* intermediate prototype to store the template string-based formatter
* function.
*/
export default (templateFn: TemplateFn) => new Printf(templateFn)
export { Printf }
|