Giter Site home page Giter Site logo

quick-format-unescaped's Introduction

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

quick-format-unescaped's People

Contributors

artskydj avatar hbacelar avatar mcollina avatar watson avatar yaroslav-korotaev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.