1.0.0 • Published 4 years ago

@alloc/log-format v1.0.0

Weekly downloads
3
License
-
Repository
-
Last release
4 years ago

@alloc/log-format

Evaluate console.log format specifiers (eg: %O) before logging.

Format specifiers:

  • %O Use pretty-format before insertion
  • %s Use String(value) before insertion
  • %f Use Number(value) before insertion
  • %d Use Math.floor(value) before insertion (alias: %i)

Example

import format from '@alloc/log-format'

format('a: %O, b: %O', /.+/, new Date)
// => 'a: /.+/, b: 2020-06-26T18:39:40.258Z'

format({ a: [1, 2], b: new Set([3, 4]) })
// => '{"a": [1, 2], "b": Set {3, 4}}'