{"_id":"theredoc","_rev":"5-b9949d4b0405313c1e2fb1e278dcdd1e","name":"theredoc","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"theredoc","version":"1.0.0","keywords":["heredoc","string","template","tag","function"],"author":{"name":"Justin Searls","email":"searls@gmail.com"},"license":"MIT","_id":"theredoc@1.0.0","maintainers":[{"name":"searls","email":"searls@gmail.com"}],"homepage":"https://github.com/testdouble/theredoc#readme","bugs":{"url":"https://github.com/testdouble/theredoc/issues"},"dist":{"shasum":"bcace376af6feb1873efbdd0f91ed026570ff062","tarball":"https://registry.npmjs.org/theredoc/-/theredoc-1.0.0.tgz","fileCount":4,"integrity":"sha512-KU3SA3TjRRM932jpNfD3u4Ec3bSvedyo5ITPI7zgWYnKep7BwQQaxlhI9qbO+lKJoRnoAbEVfMcAHRuKVYikDA==","signatures":[{"sig":"MEQCIBHeNpx6MdauSyHKjcRI1Z+WrKxUJWERnffzAWhw9jYaAiAyW3Dj2fElI6JJAX5ByHydCHQUvkY1a+QpcUNgBb2Pag==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6942,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa7cpLCRA9TVsSAnZWagAAJpgP/22dmh2y5BJ7x6T2zS7o\nEN4OSKLtlnoV+lXCPAU0511uWt7W6m+id/rae08VMrjJwoFmbG+zr7BXAU4B\n63d/2eN+5nhUklrlNAZM/mC8SC+CGi/n3JvSkz4KlQaM2u/8uRI+q1XmPfOe\naOqsHbmYXDj+QBS+rsmHxyuXryB3KX9dGEtPVUJKTxF4bVsxZ7YyLUPC8mLh\nkOLLLLxDwE4E4UBWXVP7WZ6jKhDhgY8gJtXMnie+9rH6wTO4yVFd9JgETItT\ngsJ/10zwxNO1eKp4EZM/MkHr9Fjggf0r01KL0p224ZYxk3nZY1NCedNJE3+8\nwDgA3gY5dkCjWBOIEUm/D7Vr/5VK4qdi+52I+3keGREOPFb9s4aNoc9AiqaV\ntYoSsgmXFtfALGnGYqr3KM5Aqqo1IrkuxLgh/uF13PpFYs9dDFxVnglFWhBo\nad5B0V4XKjvgcD8MvabZiv/Irc5Gi0W/U+aeer9bP5XE86tq3sKUWfiQQca8\nGViw1BMS6igbFlZaatJ14q2m/FI0aINpfm8gJpvVuGI4R9CR2HyigzhjlE3c\n+E9g/pOPWQv9FmD/v5VKJAn9r/+cDBbMauLnTZ0TB96+lQsoEvzA3hHoHt7u\nFhnmHc4Uzg7hpn/z7NnyFyaZI3aVF+79Lu2rgvUQuvfjQ5ckP5TftxcnrvoV\nCLrY\r\n=2WDX\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","gitHead":"20163f73419589a1d8a2e86105a3e0d30422e4ed","scripts":{"ci":"npm test && npm run style","test":"teenytest","style":"standard --fix"},"_npmUser":{"name":"searls","email":"searls@gmail.com"},"teenytest":{"testLocator":"test.js"},"repository":{"url":"git+https://github.com/testdouble/theredoc.git","type":"git"},"_npmVersion":"5.8.0","description":"A string template tag to strip leading indents from your heredoc-style multi-line strings","directories":{},"_nodeVersion":"8.11.1","_hasShrinkwrap":false,"devDependencies":{"standard":"^11.0.1","teenytest":"^5.1.1"},"_npmOperationalInternal":{"tmp":"tmp/theredoc_1.0.0_1525533257965_0.5731551819812672","host":"s3://npm-registry-packages"}}},"time":{"created":"2018-05-05T15:14:17.965Z","modified":"2026-09-21T16:42:33.604Z","1.0.0":"2018-05-05T15:14:18.032Z"},"bugs":{"url":"https://github.com/testdouble/theredoc/issues"},"author":{"name":"Justin Searls","email":"searls@gmail.com"},"license":"MIT","homepage":"https://github.com/testdouble/theredoc#readme","keywords":["heredoc","string","template","tag","function"],"repository":{"url":"git+https://github.com/testdouble/theredoc.git","type":"git"},"description":"A string template tag to strip leading indents from your heredoc-style multi-line strings","maintainers":[{"email":"dustin@testdouble.com","name":"dustin.tinney"},{"email":"mike@testdouble.com","name":"mike.testdouble"},{"email":"ross.brandes@gmail.com","name":"rosston"},{"email":"searls@gmail.com","name":"searls"}],"readme":"# theredoc\n\nA little tag function that strips leading indent from multi-line ES string\ntemplates. It also strips the first and last lines if they're just whitespace.\n\n## Install\n\n```\n$ npm install theredoc\n```\n\n## Usage\n\n``` js\nconst theredoc = require('theredoc')\n\nconsole.log(theredoc`\n  I want to write multipline lines\n  but don't want to mess up my indenting.\n    Ok?\n`)\n```\n\nWill output:\n\n```\nI want to write multipline lines\nbut don't want to mess up my indenting.\n  Ok?\n```\n\n## Questions\n\n### Why should I use this:\n\nBecause good messages are often long messages, but out-of-the-box, [ES template\nstrings](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)\ndon't format multi-line error and console messages gracefully.\n\nIf you're familiar with `\"\"\"`-style heredocs from CoffeeScript or the\n`<<~`-style heredoc from Ruby 2.3, you might appreciate being able to write\nmulti-line strings with an indentation level that matches the surrounding code\nlisting _without_ indenting the resulting string itself.\n\nFor example, if you want to print a multi-line error message without superfluous\nindentation in the following situation, an unadorned template string would have\nto be outdented awkwardly:\n\n```js\n        //...\n      } catch (e) {\n        console.error(`\nSomething bad happened.\n\n  Message: ${e.message}\n        `)\n      }\n      //...\n```\n\nAdditionally, to format the string neatly at all in the above will also add a\nextraneous leading and trailing line containing nothing but whitespace.\n\nInstead, `theredoc` lets you write this:\n\n```js\n        //...\n      } catch (e) {\n        console.error(theredoc`\n          Something bad happened.\n\n            Message: ${e.message}\n        `)\n      }\n      //...\n```\n\nAnd the resulting console output will be:\n\n```\nSomething bad happened.\n\n  Message: LOL errors\n```\n\nWith the leading 10 spaces stripped from each line and (since they only contain\nwhitespace) stripping the first and last lines of the template string.\n\nIf you still don't think this is nifty, I don't know what to tell you!\n\n### Why not use common-tags?\n\nThe very cool and fancy library\n[common-tags](https://github.com/declandewet/common-tags) can accomplish the\nsame thing with the `stripIndent` function it exports, however there are a few\ndownsides:\n\n* It will trim all leading and trailing whitespace, which one might want to\n  preserve\n* It has a runtime dependency on `babel-runtime`, which drastically [increases\n  the size of its\n  install](https://github.com/declandewet/common-tags/issues/108) and, because\n  babel-runtime depends on `core-js`, [sets a global\n  object](https://github.com/testdouble/testdouble.js/issues/364) that might be\n  more appropriate for an app to set than an intermediate lib\n* While common-tags is really spiffy and you should check it out to learn about\n  all the cool transforms you can do, 99.9% of the time I really just want\n  indent-stripping heredocs\n\n### What about tabs (`\\t`)?**\n\nTheredoc only deals with space character indentation, sorry!\n\nA pull request to support tabs would be considered if (a) it didn't drastically\nincrease the module's complexity, and (b) deferred to counting spaces in the\nevent that the given string had some lines indented with spaces and other with\n`\\t` tabs.\n","readmeFilename":"README.md"}