quick-format-unescaped
Solves a problem with util.format
Last updated 3 years ago by davidmarkclements .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install quick-format-unescaped 
SYNC missed versions from official npm registry.

quick-format-unescaped

unescaped ?

Sometimes you want to embed the results of quick-format into another string, and then escape the whole string.

usage

var format = require('quick-format-unescaped')
format('hello %s %j %d', ['world', [{obj: true}, 4, {another: 'obj'}]])

format(fmt, parameters, [options])

fmt

A printf-like format string. Example: 'hello %s %j %d'

parameters

Array of values to be inserted into the format string. Example: ['world', {obj:true}]

options.stringify

Passing an options object as the third parameter with a stringify will mean any objects will be passed to the supplied function instead of an the internal tryStringify function. This can be useful when using augmented capability serializers such as fast-safe-stringify or fast-redact.

caveats

By default quick-format-unescaped uses JSON.stringify instead of util.inspect, this means functions will not be serialized.

Benchmarks

Node 8.11.2

util*100000: 350.325ms
quick*100000: 268.141ms
utilWithTailObj*100000: 586.387ms
quickWithTailObj*100000: 280.200ms
util*100000: 325.735ms
quick*100000: 270.251ms
utilWithTailObj*100000: 492.270ms
quickWithTailObj*100000: 261.797ms

Node 10.4.0

util*100000: 301.035ms
quick*100000: 217.005ms
utilWithTailObj*100000: 404.778ms
quickWithTailObj*100000: 236.176ms
util*100000: 286.349ms
quick*100000: 214.646ms
utilWithTailObj*100000: 388.574ms
quickWithTailObj*100000: 226.036ms

Acknowledgements

Sponsored by nearForm

Current Tags

  • 4.0.4                                ...           latest (3 years ago)

15 Versions

  • 4.0.4                                ...           3 years ago
  • 4.0.3                                ...           4 years ago
  • 4.0.2 [deprecated]           ...           4 years ago
  • 4.0.1                                ...           5 years ago
  • 4.0.0                                ...           5 years ago
  • 3.0.3                                ...           5 years ago
  • 3.0.2                                ...           6 years ago
  • 3.0.1                                ...           6 years ago
  • 3.0.0                                ...           6 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.1.2                                ...           7 years ago
  • 1.1.1                                ...           8 years ago
  • 1.1.0                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |