Compose string template tags
import { compose } from 'string-template-format-compose'
import { inspect } from 'string-template-format-inspect'
// Create the tag
const log = compose(console.log, inspect)
// Use the tag
const num = 123
const str = 'abc'
const obj = { abc: 123, def: 456 }
const arr = [0, 1, 2]
log`number ${num}; string ${str}; object ${obj}; array ${arr}`
should print:
number 123; string 'abc'; object { abc: 123, def: 456 }; array [ 0, 1, 2 ]
import { compose, construct } from 'string-template-format-compose'
import { inspect } from 'string-template-format-inspect'
// Create the tag
const raise = error => { throw error }
const err = compose(raise, construct(TypeError, inspect))
// Use the tag
const obj = { abc: 123, def: 456 }
const key = 'ghi'
err`Object ${obj} does not have property ${key}`
should throw:
TypeError: Object { abc: 123, def: 456 } does not have property 'ghi'
Generated using TypeDoc