{"_id":"format-number-with-string","_rev":"4-8e6ecb030ed13ae3f618811161a0f69c","name":"format-number-with-string","description":"Format a number based on a format string '-£#,##0.##0'","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"format-number-with-string","version":"0.0.1","description":"Format a number based on a format string '-£#,##0.##0'","main":"index.js","scripts":{"test":"node test"},"repository":{"type":"git","url":"https://github.com/DeeLindesay/format-number-with-string.git"},"keywords":["number","format","format-string"],"author":{"name":"DeeLindesay"},"license":"MIT","dependencies":{"deconstruct-number-format":"~0.0.1","format-number":"^2.0.0"},"devDependencies":{"testit":"~1.2.0"},"gitHead":"cb5eb7c763dcaa9b502b6c220209642563716125","bugs":{"url":"https://github.com/DeeLindesay/format-number-with-string/issues"},"homepage":"https://github.com/DeeLindesay/format-number-with-string","_id":"format-number-with-string@0.0.1","_shasum":"f5156477485e63f74ee726525d3183bf67897064","_from":".","_npmVersion":"2.7.4","_nodeVersion":"0.12.2","_npmUser":{"name":"deelindesay","email":"dee@lindesay.co.uk"},"dist":{"shasum":"f5156477485e63f74ee726525d3183bf67897064","tarball":"https://registry.npmjs.org/format-number-with-string/-/format-number-with-string-0.0.1.tgz","integrity":"sha512-KillU+LjQyJsUlTD1aPZv+zoEAFk3GfpYtszC2FG1N7GMFOCcnvKwMyhcLFSsdRL5NiapjSQLguu/hGMAuWP0w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDYL3Yqu22KR8z45GX2J51L/dye9rFNu9qwUkTw0VKl0gIhAImuxJRJj4/sISS3jfRr84qwF17Gdne7N+Dy3dYmhw3g"}]},"maintainers":[{"name":"deelindesay","email":"dee@lindesay.co.uk"}]},"0.0.2":{"name":"format-number-with-string","version":"0.0.2","description":"Format a number based on a format string '-£#,##0.##0'","main":"index.js","scripts":{"test":"node test"},"repository":{"type":"git","url":"git+https://github.com/DeeLindesay/format-number-with-string.git"},"keywords":["number","format","format-string"],"author":{"name":"DeeLindesay"},"license":"MIT","dependencies":{"deconstruct-number-format":"~0.0.1","format-number":"^2.0.1"},"devDependencies":{"testit":"~1.2.0"},"gitHead":"e4c39f472fd01df3af7306ab69151cb823260929","bugs":{"url":"https://github.com/DeeLindesay/format-number-with-string/issues"},"homepage":"https://github.com/DeeLindesay/format-number-with-string#readme","_id":"format-number-with-string@0.0.2","_shasum":"eb96e8f1640c921f7414466ccf8dcb3bb6802cba","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.3.0","_npmUser":{"name":"deelindesay","email":"dee@lindesay.co.uk"},"dist":{"shasum":"eb96e8f1640c921f7414466ccf8dcb3bb6802cba","tarball":"https://registry.npmjs.org/format-number-with-string/-/format-number-with-string-0.0.2.tgz","integrity":"sha512-vM6k7XP/w4L1wSVXPFgbPcXZ7Rk4RgcwYMkuskVV1XhGTt74Rvk859xXIyNu5yvMSObdEkyEy/RJJhfw7vB38g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCPA4HZ19ga5JBk6M0Bh+Y7B26gfp6PjNrOpz2X4fUJmgIgd/9YmLIcp2iZEjsqJ65Jx+InPOMYLhyJSGpvbCewdfY="}]},"maintainers":[{"name":"deelindesay","email":"dee@lindesay.co.uk"}]}},"readme":"# format-number-with-string\r\nExpects a valid number in 'computer' format and a format string (eg '-£#,###,##0.000 /m', '(## years)') which is used to format the number.\r\n\r\nBasically a wrapper that uses deconstruct-format-string to deconstruct the format and then passes the results to format-number to do the formatting\r\n\r\n## The number\r\nCan be a number or a string of a number\r\n\r\n## Format String Can Include:\r\n- negative signs before or after prefix text or before or after suffix text\r\n- brackets as negative signs before/after prefix/suffix\r\n- prefix and suffix texts\r\n- `.` or `,` as decimal point\r\n- space or `.` or `,` as thousand separators\r\n- space or `.` or `,` as thousanths separators\r\n- `#`, `9` or `0` as number place holders\r\nIf the format string is undefined or an empty string then defaults are used (see format-number)\r\n\r\n## Use\r\n\r\n```\r\nvar format = require('format-number-with-string');\r\nvar overrideOptions = {noUnits: true, noSeparator: true};\r\n\r\nvar output1 = format(3345.23, '-£#,###,###.00');\r\nvar output2 = format(3345.23, '-£#,###,###.00', overrideOptions);\r\n\r\n```\r\n## Format Notes and Examples\r\n\r\n### Padding\r\nA `0` will pad to that position\r\n- `92332.42,'## ##0.##0 ##'`  returns '92 332.420'\r\n- `'.42','## ##0.##0 ##'`  returns '0.420'\r\n- `33, '00000'` returns '00033' \r\n\r\n### Rounding\r\nA `0` or `9` in the last decimal space will cause rounding to that number of places\r\n- `'92332.42467','## ##0.##0'`  returns '92 332.425'\r\n\r\n### Negatives\r\nWARNING - omitting a negative from the format string will return the absolute value\r\n- `'-332.42','(###.###)'`  returns '(332.42)'\r\n- `'-332.42','- ###.###'`  returns '- 332.42'\r\n- `'-332.42','###.###-'`  returns '332.42-'\r\n- `'-332.42','###.###'`  returns '332.42'\r\n\r\n### Decimal points/thousands separators in the format string:\r\nIf a format ends in a . or , then this will be taken as the decimal character UNLESS the same character is used elsewhere so:\r\n- `'923324234','#,###.'`  returns '923,324,234'\r\n- `'923324234','#.###,'`  returns '923.324.234'\r\n\r\nIf a format only has one of ',' or '.' and the character only appears once it is taken as the decimal point\r\n- `'2332.42','#,###'`  returns '2332,42'\r\n- `'2332.42','#.###'`  returns '2332.42'\r\n\r\nIf the character appears twice in the format string it is a separator\r\n- `'923324234','#,###,###'`  returns '923,324,234'\r\n\r\nWhen in doubt '.' in the format string is the decimal point, so \r\n- `'234.45645','#.###,#'` returns '234.456,45'\r\nTo create a similar structure with decimalChar as ',', just add a '.' at start or end or extend expression eg\r\n- `.#.###,#`\r\n- `#.###,#.`\r\n- `#.###.###,#`\r\n\r\n### Units/Prefix Text\r\nUnits can be before or after negative symbols.\r\nPrefix text cannot contain number placeholder characters\r\n`'-233278', '($# ###.### # per year)'` returns '($233 278 per year)'\r\n`'-233278', '$# ##0.00# #- per year'` returns '$233 278- per year';\r\n`'-456.23', '-$# ##0.00# # per year'` returns '-$456.23 per year';\r\n\r\n## Override Options\r\n\r\nAs used in format-number\r\n- `noUnits` boolean: if true will override and leave out prefix and suffix; default= false\r\n- `noSeparator` - boolean: if true will override both integer and decimals separator and leave them out\r\n\r\n\r\n## Does not work for:\r\n- structured reference numbers, eg 9999-9999\r\n- ignores and removes leading and trailing spaces (but retains those between pre/post fix and negative symbols etc)","maintainers":[{"name":"deelindesay","email":"dee@lindesay.co.uk"}],"time":{"modified":"2022-06-18T03:04:25.821Z","created":"2015-07-26T12:01:40.113Z","0.0.1":"2015-07-26T12:01:40.113Z","0.0.2":"2016-01-11T13:12:17.968Z"},"homepage":"https://github.com/DeeLindesay/format-number-with-string#readme","keywords":["number","format","format-string"],"repository":{"type":"git","url":"git+https://github.com/DeeLindesay/format-number-with-string.git"},"author":{"name":"DeeLindesay"},"bugs":{"url":"https://github.com/DeeLindesay/format-number-with-string/issues"},"license":"MIT","readmeFilename":"README.md"}