{"name":"printf","version":"0.2.5","description":"Full implementation of the `printf` family in pure JS.","keywords":["printf","formatting","sprintf","format","output","print"],"homepage":"http://www.adaltas.com/projects/node-printf","license":"BSD-3-Clause","author":{"name":"David Worms","email":"david@adaltas.com"},"maintainers":[{"name":"david","email":"david@adaltas.com"}],"contributors":[{"name":"David Worms","email":"david@adaltas.com"},{"name":"Aluísio Augusto Silva Gonçalves","email":"aluisio@aasg.name"},{"name":"Xavier Mendez","email":"jmendeth@gmail.com"},{"name":"LLeo","email":"lleoem@gmail.com"},{"name":"Derrell Lipman","email":"https://github.com/derrell"}],"main":"./lib/printf","engines":{"node":">= 0.9.0"},"directories":{"lib":"./lib","test":"./test","doc":"./doc"},"scripts":{"test":"mocha --compilers coffee:coffee-script/register --reporter dot"},"devDependencies":{"coffee-script":"1.10.0","should":"9.0.2","mocha":"2.5.3","semver":"5.1.1"},"repository":{"type":"git","url":"git+https://github.com/wdavidw/node-printf.git"},"bugs":{"url":"https://github.com/wdavidw/node-printf/issues"},"gitHead":"f2a6a6d8a52c8561fca3b2e32844be163b272474","_id":"printf@0.2.5","_shasum":"c438ca2ca33e3927671db4ab69c0e52f936a4f0f","_from":".","_npmVersion":"3.8.6","_nodeVersion":"6.0.0","_npmUser":{"name":"david","email":"david@adaltas.com"},"dist":{"shasum":"c438ca2ca33e3927671db4ab69c0e52f936a4f0f","tarball":"http://registry-npm.ywwl.com/printf/download/printf-0.2.5.tgz","integrity":"sha512-XHV6WP6xUvy42gUxdNyPQKCC9j36VzpVQ8Ztoffq0D6+PugiNsZ0FqBladXXPFQWthDDCA9OvGIsjEigMtznOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBWHN1fSXcLSbOqAXw+j8IVMzuWI6WZ+2xuNDUZwSZ6VAiEA4zJ9dkg5eVN2AVjgG/9Ql75nfJRkHOTvgo2c9kP5Rfk="}],"size":8847,"noattachment":false,"key":"/printf/-/printf-0.2.5.tgz"},"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/printf-0.2.5.tgz_1467888426964_0.21776666096411645"},"readme":"[![Build Status](https://secure.travis-ci.org/adaltas/node-printf.svg)](http://travis-ci.org/adaltas/node-printf)\n\nA complete implementation of the **`printf` C functions family**\nfor [Node.JS][node], written in pure JavaScript.\n\n**Bonus!** You get extra features, like the `%O` converter (which `inspect`s\nthe argument). See [Extra Features](#extra-features) below.\n\n## Installing\n\nVia [NPM][npm]:\n\n``` bash\n$ npm install printf\n```\n\n## Usage\n\nUse it like you would in C (`printf`/`sprintf`):\n\n``` javascript\nvar printf = require('printf');\nvar result = printf(format, args...);\n```\n\nIt can also output the result for you, as `fprintf`:\n\n``` javascript\nvar printf = require('printf');\nprintf(write_stream, format, args...);\n```\n\n## Features\n\n### Flag ` ` (space)\n\n``` javascript\nassert.eql('  -42', printf('% 5d', -42));\n```\n\n### Flag `+` (plus)\n\n``` javascript\nassert.eql('  +42', printf('%+5d', 42));\n```\n\n### Flag `0` (zero)\n\n``` javascript\nassert.eql('00042', printf('%05d', 42));\n```\n\n### Flag `-` (minus)\n\n``` javascript\nassert.eql('42   ', printf('%-5d', 42));\n```\n\n### Width / precision\n\n``` javascript\nassert.eql('42.90', printf('%.2f', 42.8952));\nassert.eql('042.90', printf('%06.2f', 42.8952));\n```\n\n### Numerical bases\n\n``` javascript\nassert.eql('\\x7f', printf('%c', 0x7f));\nassert.eql('a', printf('%c', 'a'));\nassert.eql('\"', printf('%c', 34));\n```\n\n### Miscellaneous\n\n``` javascript\nassert.eql('10%', printf('%d%%', 10));\nassert.eql('+hello+', printf('+%s+', 'hello'));\nassert.eql(\"a\", printf(\"%c\", \"a\"));\nassert.eql('\"', printf(\"%c\", 34));\nassert.eql('$', printf('%c', 36));\nassert.eql(\"10\", printf(\"%d\", 10));\n```\n\n## Extra features!\n\n### Inspector\n\nThe `%O` converter will call [`util.inspect(...)`][util_inspect] at the argument:\n\n``` javascript\nassert.eql(\"Debug: { hello: 'Node', repeat: false }\",\n  printf('Debug: %O', {hello: 'Node', \"repeat\": false})\n);\nassert.eql(\"Test: { hello: 'Node' }\",\n  printf('%2$s: %1$O', {\"hello\": 'Node'}, 'Test')\n);\n```\n\n**Important:** it's a capital \"O\", *not* a zero!\n\nSpecifying a precision lets you control the depth up to which the object is formatted:\n\n``` javascript\nassert.eql(\"Debug: { depth0: { depth1_: 0, depth1: [Object] } }\",\n  printf('Debug: %.1O', {depth0: {depth1: {depth2: {depth3: true}}, depth1_: 0}})\n);\n```\n\nYou can use the alternative form flag together with `%O` to disable representation of non-enumerable properties (useful for arrays):\n\n``` javascript\nassert.eql(\"With non-enumerable properties: [ 1, 2, 3, 4, 5, [length]: 5 ]\",\n  printf('With non-enumerable properties: %O', [1, 2, 3, 4, 5])\n);\nassert.eql(\"Without non-enumerable properties: [ 1, 2, 3, 4, 5 ]\",\n  printf('Without non-enumerable properties: %#O', [1, 2, 3, 4, 5])\n);\n```\n\nYou can use the sign flag together with `%O` to enable colors in `util.inspect`:\n\n``` javascript\nassert.eql(\"With colors: { bar: \\u001b[33mtrue\\u001b[39m, baz: \\u001b[33mfalse\\u001b[39m }\",\n  printf('With colors: %+O', {bar: true, baz: false})\n);\n```\n\n### Argument mapping\n\nIn addition to the old-fashioned `n$`,\nyou can use **hashes** and **property names**!\n\n``` javascript\nassert.eql('Hot Pockets',\n  printf('%(temperature)s %(crevace)ss', {\n    temperature: 'Hot',\n    crevace: 'Pocket'\n  })\n);\nassert.eql('Hot Pockets',\n  printf('%2$s %1$ss', 'Pocket', 'Hot')\n);\n```\n\n### Positionals\n\nLength and precision can now be variable:\n\n``` javascript\nassert.eql(' foo', printf('%*s', 'foo', 4));\nassert.eql('      3.14', printf('%*.*f', 3.14159265, 10, 2));\nassert.eql('000003.142', printf('%0*.*f', 3.14159265, 10, 3));\nassert.eql('3.1416    ', printf('%-*.*f', 3.14159265, 10, 4));\n```\n\n## Development\n\nTests are written in [CoffeeScript][coffee] and are executed with [Mocha][mocha]. To use it, simple run `npm install`, it will install Mocha and its dependencies in your project's `node_modules` directory followed by `npm test`.\n\nTo run the tests:\n\n```bash\nnpm install\nnpm test\n```\n\nThe test suite is run online with [Travis][travis] against the versions 6, 7, 8 and 9 of Node.js.\n\n## Contributors\n\n*   David Worms <https://github.com/wdavidw>\n*   Aluísio Augusto Silva Gonçalves <https://github.com/AluisioASG>\n*   Xavier Mendez <https://github.com/jmendeth>\n*   LLeo <https://github.com/lleo>\n*   Derrell Lipman <https://github.com/derrell>\n\nThis package is developed by [Adaltas](http://www.adaltas.com).\n\n[node]: http://nodejs.org \"The Node.JS platform\"\n[npm]:  https://github.com/isaacs/npm \"The Node Package Manager\"\n[util_inspect]: http://nodejs.org/api/util.html#util_util_inspect_object_showhidden_depth_colors \"util.inspect() documentation\"\n[travis]: https://travis-ci.org \"Continuous Integration system\"\n[mocha]: http://mochajs.org/ \"The Mocha test framework\"\n[coffee]: http://coffeescript.org/\n","publish_time":1467888428334,"_cnpm_publish_time":1467888428334,"dist-tags":{"latest":"0.6.1"}}