{"author":{"name":"Gajus Kuizinas","email":"gajus@gajus.com","url":"http://gajus.com"},"ava":{"extensions":["ts"],"files":["test/fast-printf/**/*"],"require":["ts-node/register/transpile-only"]},"dependencies":{"boolean":"^3.0.2","mathjs":"^9.2.0"},"description":"Fast and spec-compliant printf implementation for Node.js and browser.","devDependencies":{"@istanbuljs/nyc-config-typescript":"^1.0.1","@types/mathjs":"^6.0.11","ava":"^3.15.0","benchmark":"^2.1.4","coveralls":"^3.1.0","del-cli":"^3.0.1","eslint":"^7.20.0","eslint-config-canonical":"^25.9.0","husky":"^4","nyc":"^15.1.0","semantic-release":"^17.3.9","ts-node":"^9.1.1","typescript":"^4.2.2"},"engines":{"node":">=10.0"},"exports":{".":{"default":"./dist/esm/src/printf.js","require":"./dist/cjs/src/printf.js"}},"husky":{"scripts":{"pre-commit":"npm run lint && npm run test && npm run build"}},"keywords":["printf","sprintf"],"license":"BSD-3-Clause","main":"./dist/cjs/src/printf.js","name":"fast-printf","repository":{"type":"git","url":"git+ssh://git@github.com/gajus/fast-printf.git"},"scripts":{"benchmark":"ROARR_LOG=true ts-node --transpile-only test/benchmark.ts","build":"del-cli ./dist && tsc && tsc -p tsconfig-esm.json","dev":"tsc --watch","lint":"eslint ./src ./test && tsc --noEmit","test":"NODE_ENV=test ava --serial --verbose"},"typings":"./dist/esm/src/printf.d.ts","version":"1.6.1","gitHead":"9fa7e0c4a0a0cd43a62212bb89cb6ad3be8442e9","bugs":{"url":"https://github.com/gajus/fast-printf/issues"},"homepage":"https://github.com/gajus/fast-printf#readme","_id":"fast-printf@1.6.1","_nodeVersion":"10.24.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-Dao7UJhUT/RQ4AtjfTgnwYLyH1kRS5OCWw7PYOYhe6Qh2Td1ybA5eatLbgHAQAqcq7CcgB5xBSkz395ISl2Pjg==","shasum":"c284a189db22494e63fcc3d9af9905f6e267a150","tarball":"http://registry-npm.ywwl.com/fast-printf/download/fast-printf-1.6.1.tgz","fileCount":29,"unpackedSize":45263,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOCgZCRA9TVsSAnZWagAAHMEP/2XWfZS0/0vp0Ohgb6xO\nnlZK6pE+NWPeXJFy86+5KtssHvIwIsi/i+o7/nVWJpu8am52oBFEkabNZfli\nqcY6XTa4/zgy5iEK9tKd7XuXm0n4Y/CYKWtMZw44+dLs4Y6S1N6WhM7CeaTd\n2n1UAecQsxoH/yPALzb+WWpt6TEN51F/97UrAdB9XlJGBqdwQgHUiDR6Ab+R\nzIAADAcutpVqqiI70joQy2IhaEbzXdUIUkwHzYfyhpr1DplOn0QvS+vSIpBQ\nagoa9m+LSBHiAxBuMa0AJFWZqkSw91wcEsCRizjh9rObYF3XWFob6bn7PUzr\ndhVI1gpCjLclWEW7XC/QLADr2lsQTssnLn3wvGKkskTcORyErqeU8fWrkxw7\nWsVttjiR0lojqJEBSbSnh1upxboF1FxJlY366oN1EIzirvkD919NnLk0SDY8\nncx9G8woCw687aKhcUsnePa2wiB5+fMIvLs1uOxzbo89b7jI1iDvEaIdoL+r\n7E3Kipn0nkRhDpj8SSsxso1JdZxOwCXsTAy7LrQMlIocg6+Dwaza1QSri6Jb\n69QGOp6D30spl6JzrfyGAXzeARmAI35oVDDAXfifdU1j0vuXhaEHl5XdfUij\nNvIclsos9SpuyPjmNyrQI9hJNAyfiDLdDJFMgNy9PI3vTD5Z1FnQp6ugGGjo\nClLU\r\n=lMAc\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF3Yzv1V4XS1PvArhKI7y1Xhr+WOXF40qlO+imHOB+ZJAiANqS0wso43Z051hkThq/B/CvrDKEFoRSjfNV7uN03kUA=="}],"size":7902,"noattachment":false,"key":"/fast-printf/-/fast-printf-1.6.1.tgz"},"_npmUser":{"name":"gajus","email":"gajus@gajus.com"},"directories":{},"maintainers":[{"name":"gajus","email":"gajus@gajus.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fast-printf_1.6.1_1614293017112_0.41259652722425555"},"_hasShrinkwrap":false,"readme":"# fast-printf\n\n[![Travis build status](http://img.shields.io/travis/gajus/fast-printf/master.svg?style=flat-square)](https://travis-ci.org/gajus/fast-printf)\n[![Coveralls](https://img.shields.io/coveralls/gajus/fast-printf.svg?style=flat-square)](https://coveralls.io/github/gajus/fast-printf)\n[![NPM version](http://img.shields.io/npm/v/fast-printf.svg?style=flat-square)](https://www.npmjs.org/package/fast-printf)\n[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)\n[![Twitter Follow](https://img.shields.io/twitter/follow/kuizinas.svg?style=social&label=Follow)](https://twitter.com/kuizinas)\n\n[Fast](#benchmark) and spec-compliant `printf` implementation for Node.js and browser.\n\n* [Usage](#usage)\n* [Handling Unbound Value References](#handling-unbound-value-references)\n* [Benchmark](#benchmark)\n* [Printf Cheatsheet](#printf-cheatsheet)\n\n## Usage\n\n```ts\nimport {\n  printf,\n} from 'fast-printf';\n\nconsole.log(printf('foo %s', 'bar'));\n\n```\n\n## Handling Unbound Value References\n\nBy default, interpolating an unbound expression produces:\n\n* The expression is left in place\n* A warning is logged using [roarr](https://github.com/gajus/roarr)\n\ni.e. `printf('%s bar')` produces `%s bar`.\n\nThis behavior can be overridden by configuring a `fast-printf` instance using `createPrintf`:\n\n```ts\nimport {\n  createPrintf,\n} from 'fast-printf';\n\nconst printf = createPrintf({\n  formatUnboundExpression: (\n    subject: string,\n    token: PlaceholderToken,\n    boundValues: any[],\n  ): string => {\n    console.warn({\n      boundValues,\n      position: token.position,\n      subject,\n    }, 'referenced unbound value');\n\n    return token.placeholder;\n  };\n});\n\nconsole.log(printf('foo %s', 'bar'));\n\n```\n\n## Benchmark\n\n|**implementation**|**without_placeholders**|**with_string_placeholder**|**with_many_string_placeholders**|\n|-|-|-|-|\n|[`sprintf`](https://github.com/alexei/sprintf.js)|31,772,029|4,154,748|637,229|\n|[`printf`](https://github.com/adaltas/node-printf)|651,970|373,615|160,795|\n|[`fast-printf`](https://github.com/gajus/fast-printf)|78,068,540|11,820,632|2,552,386|\n\nResults show operations per second (greater is better).\n\nTo run the benchmark yourself please see [`./benchmark`](./benchmark).\n\n## Printf Cheatsheet\n\n```ts\n// %c character\nprintf('%c', 'b');\n// => 'c'\n\n// %C converts to uppercase character (if not already)\nprintf('%C', 'b');\n// => 'B'\n\n// %d decimal integer (base 10)\nprintf('%d', 100);\n// => '100'\n\n// %0Xd zero-fill for X digits\nprintf('%05d', 1);\n// => '00001'\n\n// %Xd right justify for X digits\nprintf('%5d', 1);\n// => '    1'\n\n// %-Xd left justify for X digits\nprintf('%-5d', 1);\n// => '1    '\n\n// %+d adds plus sign(+) to positive integers, minus sign for negative integers(-)\nprintf('%+5d', 1);\n// => '    +1'\nprintf('%+5d', -1);\n// => '    -1'\n\n// %e scientific notation\nprintf('%e', 52.8);\n// => '5.28e+1'\n\n// %E scientific notation with a capital 'E'\nprintf('%E', 52.8);\n// => '5.28E+1'\n\n// %f floating-point number\nprintf('%f', 52.8);\n// => '52.8'\n\n// %.Yf prints Y positions after decimal\nprintf('%.1f', 1.234);\n// => '1.2'\n\n// %Xf takes up X spaces\nprintf('%5f', 123);\n// => '  123'\n\n// %0X.Yf zero-fills\nprintf('%05.1f', 1.234);\n// => '001.2'\n\n// %-X.Yf left justifies\nprintf('%-5.1f', 1.234);\n// => '1.2  '\n\n// %i integer (base 10)\nprintf('%i', 123);\n// => '123'\n\n// %b converts to boolean\nprintf('%b', true);\n// => 'true'\nprintf('%b', 'true');\n// => 'true'\nprintf('%b', 1);\n// => 'true'\n\n// %B converts to uppercase boolean\nprintf('%b', true);\n// => 'TRUE'\nprintf('%b', 'true');\n// => 'TRUE'\nprintf('%b', 1);\n// => 'TRUE'\n\n// %o octal number (base 8)\nprintf('%o', 8);\n// => '10'\n\n// %s a string of characters\nprintf('%s', 'foo');\n// => 'foo'\n\n// %Xs formats string for a minimum of X spaces\nprintf('%5s', 'foo');\n// => '  foo'\n\n// %-Xs left justify\nprintf('%-5s', 'foo');\n// => 'foo  '\n\n// %S converts to a string of uppercase characters (if not already)\nprintf('%S', 'foo');\n// => 'FOO'\n\n// %u unsigned decimal integer\nprintf('%u', 1);\n// => '1'\nprintf('%u', -1);\n// => '4294967295'\n\n// %x number in hexadecimal (base 16)\nprintf('%x', 255);\n// => 'ff'\n\n// %% prints a percent sign\nprintf('%%');\n// => '%'\n\n// \\% prints a percent sign\nprintf('\\\\%');\n// => '%'\n\n// %2$s %1$s positional arguments\nprintf('%2$s %1$s', 'bar', 'foo');\n// => 'foo bar'\n\n```\n","publish_time":1614293017237,"_cnpm_publish_time":1614293017237,"dist-tags":{"latest":"1.6.10"}}