{"_id":"string-format","_rev":"28-f5ca9d48a0ecec0dcf729a9cee2c49be","name":"string-format","dist-tags":{"latest":"2.0.0"},"versions":{"0.1.0":{"name":"string-format","version":"0.1.0","keywords":["string","formatting","language","util"],"author":{"name":"David Chambers","email":"dc@hashify.me"},"_id":"string-format@0.1.0","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"homepage":"https://bitbucket.org/davidchambers/string-format","bugs":{"name":"https://bitbucket.org/davidchambers/string-format/issues"},"dist":{"shasum":"c7951ad47e3c5bd18fa145aac7869505c8421b3b","tarball":"https://registry.npmjs.org/string-format/-/string-format-0.1.0.tgz","integrity":"sha512-J8L1TssUSBud+t8fhBDPO0JM8grzt3BCBO0949u19kbVgrv4KNjl2A4qzV6KCLN7PELzVDJcaCRHx8hVx4/0Gg==","signatures":[{"sig":"MEYCIQDZsvXBv5Jye1VBnZaBZCPyGSaBW/07nuYYuAKPphRWqQIhAOXcFeE5S7gpzImSfsYTKhWKu41xlqDklM4xZsE/QjNc","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"string-format.js","engines":{"node":"*"},"_npmUser":{"name":"davidchambers","email":"dc@hashify.me"},"repository":{"url":"https://bitbucket.org/davidchambers/string-format","type":"hg"},"_npmVersion":"1.0.105","description":"Adds a `format` method to `String.prototype`. Inspired by Python's `str.format()`.","directories":{},"_nodeVersion":"v0.6.0","dependencies":{},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":true},"0.2.0":{"name":"string-format","version":"0.2.0","keywords":["string","formatting","language","util"],"author":{"name":"David Chambers","email":"dc@hashify.me"},"_id":"string-format@0.2.0","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"homepage":"https://github.com/davidchambers/string-format","bugs":"https://github.com/davidchambers/string-format/issues","dist":{"shasum":"88b6c0a3081051583bb1d3398e170c9e09e954d1","tarball":"https://registry.npmjs.org/string-format/-/string-format-0.2.0.tgz","integrity":"sha512-AJdlNFW0HtDbsWL51STr9bG/W6Q+xOaWXF9llxG3OuNcpvz9J9+HFQK0c/k1dQVp2mg2cMd4nqdKxwkeXFb+nw==","signatures":[{"sig":"MEQCICo3DpJyEVPzkSdR8jSJktDSH072pWeiTyAkRM1oI3rTAiAfP3SPSvv3bmSdlxCIlT0Skimge1BL6i/H9tx2rUCO5w==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"string-format.js","scripts":{"test":"node_modules/jessie/bin/jessie spec"},"repository":{"url":"https://github.com/davidchambers/string-format","type":"git"},"description":"Adds a `format` method to `String.prototype`. Inspired by Python's `str.format()`.","directories":{},"devDependencies":{"jessie":"0.4.x","coffee-script":"1.3.x"}},"0.2.1":{"name":"string-format","version":"0.2.1","keywords":["string","formatting","language","util"],"author":{"name":"David Chambers","email":"dc@hashify.me"},"_id":"string-format@0.2.1","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"homepage":"https://github.com/davidchambers/string-format","bugs":"https://github.com/davidchambers/string-format/issues","dist":{"shasum":"e88f015d5524ebc209ac627586e8d1fdcc62bca1","tarball":"https://registry.npmjs.org/string-format/-/string-format-0.2.1.tgz","integrity":"sha512-oFyZFWhc2ZbuI7KXsmzJ5iiQMjfqu5/pgPSekGCHi7joUabKPXNEbsEHHiIrKSu82zj2CN4PqvR9I04oA4gR/A==","signatures":[{"sig":"MEUCIDnNbRrft/xSxciATZ3yumXjRe1mq00zDAj1OySTDh5CAiEAttKA5iiJ19/uWfyp6FxsWw5b0s6faf6bFks4tu1AeKM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/string-format","licenses":[{"url":"https://raw.github.com/davidchambers/string-format/master/LICENSE","type":"WTFPL"}],"repository":{"url":"git://github.com/davidchambers/string-format.git","type":"git"},"description":"Adds a `format` method to `String.prototype`. Inspired by Python's `str.format()`.","directories":{},"devDependencies":{"mocha":"1.7.x","should":"1.2.x","coffee-script":"1.4.x"}},"0.5.0":{"name":"string-format","version":"0.5.0","keywords":["string","formatting","language","util"],"author":{"name":"David Chambers","email":"dc@davidchambers.me"},"_id":"string-format@0.5.0","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"homepage":"https://github.com/davidchambers/string-format","bugs":{"url":"https://github.com/davidchambers/string-format/issues"},"dist":{"shasum":"bfc4a69a250f17f273d97336797daf5dca6ecf30","tarball":"https://registry.npmjs.org/string-format/-/string-format-0.5.0.tgz","integrity":"sha512-c/CiKQMy7uuEzi+Tsvnn63/PQw/F7IOSLHNuQ44Eypd0x5VvFnDXMd2T9H0ntphv8nrHAKoZcINPb/yitOAB/g==","signatures":[{"sig":"MEUCIQCEPqzu2vm0N6Kpg31/VkkgD4jC+Ox7bFgB4U5KC2uzTgIgRScao20RQyVxPTaUk2cqZk4Mtgnd41e0HebHttrxkTs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/string-format","_from":".","files":["README.md","lib/string-format.js","package.json"],"_shasum":"bfc4a69a250f17f273d97336797daf5dca6ecf30","gitHead":"e98595d385a460edb8fe9bd384fe1af3da307a31","scripts":{"test":"make test","prepublish":"make clean && make"},"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"licenses":[{"url":"https://raw.github.com/davidchambers/string-format/master/LICENSE","type":"WTFPL"}],"repository":{"url":"git://github.com/davidchambers/string-format.git","type":"git"},"_npmVersion":"1.4.28","description":"Adds a `format` method to `String.prototype`. Inspired by Python's `str.format()`.","directories":{},"devDependencies":{"xyz":"0.5.x","mocha":"2.x.x","ramda":"0.8.x","coffee-script":"1.8.x"}},"1.0.0":{"name":"string-format","version":"1.0.0","keywords":["string","formatting","language","util"],"author":{"name":"David Chambers","email":"dc@davidchambers.me"},"license":"(WTFPL OR MIT)","_id":"string-format@1.0.0","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"homepage":"https://github.com/davidchambers/string-format","bugs":{"url":"https://github.com/davidchambers/string-format/issues"},"dist":{"shasum":"a43a829cd2a6c3cba22076070697ad4e4836eb3f","tarball":"https://registry.npmjs.org/string-format/-/string-format-1.0.0.tgz","fileCount":4,"integrity":"sha512-SftjZ0Ks8hiWQx+eknh6EguF8bRpj5JWQKizpQQ5ARx7vyOCeNuBv80KRfvRhmVTQyAGWvLe37cOB8L5CpkC3A==","signatures":[{"sig":"MEUCIQCE14KsRHA6dGu0g12Z3VHXLOYQA/Bz2usUre7al0YCAQIgTjxM+J3oWmnB6wP0pe5k4lr56adTiMKYelOuvjgk3DQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9549},"files":["LICENSE","README.md","index.js","package.json"],"gitHead":"ffa4f14db38a479d977edbfd27b39b684935a19e","scripts":{"lint":"sanctuary-lint","test":"npm run lint && sanctuary-test && npm run doctest","doctest":"sanctuary-doctest","release":"sanctuary-release"},"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"repository":{"url":"git://github.com/davidchambers/string-format.git","type":"git"},"_npmVersion":"5.6.0","description":"String formatting inspired by Python's str.format()","directories":{},"_nodeVersion":"8.9.4","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"sanctuary-scripts":"1.2.x"},"_npmOperationalInternal":{"tmp":"tmp/string-format_1.0.0_1522066555921_0.777248633674454","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"string-format","version":"2.0.0","keywords":["string","formatting","language","util"],"author":{"name":"David Chambers","email":"dc@davidchambers.me"},"license":"WTFPL OR MIT","_id":"string-format@2.0.0","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"homepage":"https://github.com/davidchambers/string-format","bugs":{"url":"https://github.com/davidchambers/string-format/issues"},"dist":{"shasum":"f2df2e7097440d3b65de31b6d40d54c96eaffb9b","tarball":"https://registry.npmjs.org/string-format/-/string-format-2.0.0.tgz","fileCount":4,"integrity":"sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==","signatures":[{"sig":"MEUCIQDE0K1OV7g0h1fSmiRL59Y03AnJ9mjvEHuxBKbKl0ejXQIgVtPxhXhZDZ5KTja6qRPph7/fDGxXTvW+TxufGR7DEW8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9925,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa/qggCRA9TVsSAnZWagAAKgEQAJzC5Wc3QjwoajYkIOE2\n6IfpCLpcYrYcgdV0azjB6AZfd8mfpKfN9pjhVP/G0Cb1ELWenjtaQucWtjOD\n28OG/8OAh/QrbxDOS9AFnZqmxPUYCuJTGgFIxBVzphZ/O/4rs/4nHkfO9irY\noh1enrxAbOKvLCeZG/E4FyrDK1+Iklj6y2/GuQNJUW4KmGd/XfN8Y9nXeUGI\nslJRw9ErptPcKsEYLw2ErOl/9UPMrqXUsg6a54c/7j4xzM+hl75u5aACw9wa\ny93N+lXLO1Fi9k8VIfr+n3/hXHw/Uq6fiyXXSDPu8Zr794dun+rgRy4N27z4\nGRXZYriFszDCZYHV24Wk/ddygpsxdHpKTGTNSCtyjmZ7eBfw1IdK4fYJJWl1\nn0oRWlymmpr2lExLu4GH9Msp4fGKkqWPQxB69uwZlQ3u0l4uufbsVKMedDHl\ndEB262czt4LBVLWS6oVRKFvl2uIjDPHSzL6d1EotPhZqvtx12ZnVmgaqxuE1\nAWmRVeP2dpQEwHkcG6CxV8a/otzAJ2K4HQFk93CsPp/7SDJQ+E0nJ07zp1eY\nnGQSjUNbIleevgnLBjLtiRyupkFQDylCG0N/g3KbFIwul/SjE9Ppn4iJnCUR\n5JVT4v3ZzyA8EbFWoJ2tsHiG7yEPqQbfMVoFKFhknxq8lOj/4pk/V1KbBfoV\n4Lsj\r\n=gWTg\r\n-----END PGP SIGNATURE-----\r\n"},"files":["LICENSE","README.md","index.js","package.json"],"gitHead":"e6ae5db261a06d09f23788f33884dda24490c3f6","scripts":{"lint":"sanctuary-lint","test":"npm run lint && sanctuary-test && npm run doctest","doctest":"sanctuary-doctest","release":"sanctuary-release"},"_npmUser":{"name":"davidchambers","email":"dc@davidchambers.me"},"repository":{"url":"git://github.com/davidchambers/string-format.git","type":"git"},"_npmVersion":"5.6.0","description":"String formatting inspired by Python's str.format()","directories":{},"_nodeVersion":"10.1.0","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"sanctuary-scripts":"1.6.x"},"_npmOperationalInternal":{"tmp":"tmp/string-format_2.0.0_1526638623908_0.7596257511300173","host":"s3://npm-registry-packages"}}},"time":{"created":"2012-02-07T05:58:59.512Z","modified":"2026-07-17T17:10:11.208Z","0.1.0":"2012-02-07T05:59:00.946Z","0.2.0":"2012-09-03T23:07:59.455Z","0.2.1":"2012-12-16T21:54:26.581Z","0.5.0":"2015-01-24T07:05:32.068Z","1.0.0":"2018-03-26T12:15:56.082Z","2.0.0":"2018-05-18T10:17:04.009Z"},"bugs":{"url":"https://github.com/davidchambers/string-format/issues"},"author":{"name":"David Chambers","email":"dc@davidchambers.me"},"license":"WTFPL OR MIT","homepage":"https://github.com/davidchambers/string-format","keywords":["string","formatting","language","util"],"repository":{"url":"git://github.com/davidchambers/string-format.git","type":"git"},"description":"String formatting inspired by Python's str.format()","maintainers":[{"name":"davidchambers","email":"dc@hashify.me"}],"readme":"# string-format\n\nstring-format is a small JavaScript library for formatting strings, based on\nPython's [`str.format()`][1]. For example:\n\n```javascript\n'\"{firstName} {lastName}\" <{email}>'.format(user)\n// => '\"Jane Smith\" <jsmith@example.com>'\n```\n\nThe equivalent concatenation:\n\n```javascript\n'\"' + user.firstName + ' ' + user.lastName + '\" <' + user.email + '>'\n// => '\"Jane Smith\" <jsmith@example.com>'\n```\n\n### Installation\n\n#### Node\n\n1.  Install:\n\n    ```console\n    $ npm install string-format\n    ```\n\n2.  Require:\n\n    ```javascript\n    const format = require('string-format')\n    ```\n\n#### Browser\n\n1.  Define `window.format`:\n\n    ```html\n    <script src=\"path/to/string-format.js\"></script>\n    ```\n\n### Modes\n\nstring-format can be used in two modes: [function mode](#function-mode) and\n[method mode](#method-mode).\n\n#### Function mode\n\n```javascript\nformat('Hello, {}!', 'Alice')\n// => 'Hello, Alice!'\n```\n\nIn this mode the first argument is a template string and the remaining\narguments are values to be interpolated.\n\n#### Method mode\n\n```javascript\n'Hello, {}!'.format('Alice')\n// => 'Hello, Alice!'\n```\n\nIn this mode values to be interpolated are supplied to the `format` method\nof a template string. This mode is not enabled by default. The method must\nfirst be defined via [`format.extend`](#formatextendprototype-transformers):\n\n```javascript\nformat.extend(String.prototype, {})\n```\n\n`format(template, $0, $1, …, $N)` and `template.format($0, $1, …, $N)` can then\nbe used interchangeably.\n\n### `format(template, $0, $1, …, $N)`\n\nReturns the result of replacing each `{…}` placeholder in the template string\nwith its corresponding replacement.\n\nPlaceholders may contain numbers which refer to positional arguments:\n\n```javascript\n'{0}, you have {1} unread message{2}'.format('Holly', 2, 's')\n// => 'Holly, you have 2 unread messages'\n```\n\nUnmatched placeholders produce no output:\n\n```javascript\n'{0}, you have {1} unread message{2}'.format('Steve', 1)\n// => 'Steve, you have 1 unread message'\n```\n\nA format string may reference a positional argument multiple times:\n\n```javascript\n\"The name's {1}. {0} {1}.\".format('James', 'Bond')\n// => \"The name's Bond. James Bond.\"\n```\n\nPositional arguments may be referenced implicitly:\n\n```javascript\n'{}, you have {} unread message{}'.format('Steve', 1)\n// => 'Steve, you have 1 unread message'\n```\n\nA format string must not contain both implicit and explicit references:\n\n```javascript\n'My name is {} {}. Do you like the name {0}?'.format('Lemony', 'Snicket')\n// => ValueError: cannot switch from implicit to explicit numbering\n```\n\n`{{` and `}}` in format strings produce `{` and `}`:\n\n```javascript\n'{{}} creates an empty {} in {}'.format('dictionary', 'Python')\n// => '{} creates an empty dictionary in Python'\n```\n\nDot notation may be used to reference object properties:\n\n```javascript\nconst bobby = {firstName: 'Bobby', lastName: 'Fischer'}\nconst garry = {firstName: 'Garry', lastName: 'Kasparov'}\n\n'{0.firstName} {0.lastName} vs. {1.firstName} {1.lastName}'.format(bobby, garry)\n// => 'Bobby Fischer vs. Garry Kasparov'\n```\n\n`0.` may be omitted when referencing a property of `{0}`:\n\n```javascript\nconst repo = {owner: 'davidchambers', slug: 'string-format'}\n\n'https://github.com/{owner}/{slug}'.format(repo)\n// => 'https://github.com/davidchambers/string-format'\n```\n\nIf the referenced property is a method, it is invoked with no arguments to\ndetermine the replacement:\n\n```javascript\nconst sheldon = {\n  firstName: 'Sheldon',\n  lastName: 'Cooper',\n  dob: new Date('1970-01-01'),\n  fullName: function() { return this.firstName + ' ' + this.lastName },\n  quip: function() { return 'Bazinga!' },\n}\n\n'{fullName} was born at precisely {dob.toISOString}'.format(sheldon)\n// => 'Sheldon Cooper was born at precisely 1970-01-01T00:00:00.000Z'\n\n\"I've always wanted to go to a goth club. {quip.toUpperCase}\".format(sheldon)\n// => \"I've always wanted to go to a goth club. BAZINGA!\"\n```\n\n### `format.create(transformers)`\n\nThis function takes an object mapping names to transformers and returns a\nformatting function. A transformer is applied if its name appears, prefixed\nwith `!`, after a field name in a template string.\n\n```javascript\nconst fmt = format.create({\n  escape: s => s.replace(/[&<>\"'`]/g, c => '&#' + c.charCodeAt(0) + ';'),\n  upper: s => s.toUpperCase(),\n})\n\nfmt('Hello, {!upper}!', 'Alice')\n// => 'Hello, ALICE!'\n\nconst restaurant = {name: 'Anchor & Hope', url: 'http://anchorandhopesf.com/'}\n\nfmt('<a href=\"{url!escape}\">{name!escape}</a>', restaurant)\n// => '<a href=\"http://anchorandhopesf.com/\">Anchor &#38; Hope</a>'\n```\n\n### `format.extend(prototype, transformers)`\n\nThis function takes a prototype (presumably `String.prototype`) and an object\nmapping names to transformers, and defines a `format` method on the prototype.\nA transformer is applied if its name appears, prefixed with `!`, after a field\nname in a template string.\n\n```javascript\nformat.extend(String.prototype, {\n  escape: s => s.replace(/[&<>\"'`]/g, c => '&#' + c.charCodeAt(0) + ';'),\n  upper: s => s.toUpperCase(),\n})\n\n'Hello, {!upper}!'.format('Alice')\n// => 'Hello, ALICE!'\n\nconst restaurant = {name: 'Anchor & Hope', url: 'http://anchorandhopesf.com/'}\n\n'<a href=\"{url!escape}\">{name!escape}</a>'.format(restaurant)\n// => '<a href=\"http://anchorandhopesf.com/\">Anchor &#38; Hope</a>'\n```\n\n### Running the test suite\n\n```console\n$ npm install\n$ npm test\n```\n\n\n[1]: http://docs.python.org/library/stdtypes.html#str.format\n","readmeFilename":"README.md","users":{"sunggun":true,"codekiln":true,"banderror":true,"davidbraun":true,"f124275809":true,"icerainnuaa":true,"eladkeyshawn":true,"shanewholloway":true,"programmer.severson":true}}