{"name":"spacetrim","version":"0.11.21","keywords":[],"author":"","license":"SEE LICENSE IN LICENSE","_id":"spacetrim@0.11.21","homepage":"https://github.com/hejny/spacetrim#readme","bugs":{"url":"https://github.com/hejny/spacetrim/issues"},"dist":{"shasum":"0a11e5253479a0bb3e41c5b136f574b110d839d9","tarball":"http://registry-npm.ywwl.com/spacetrim/download/spacetrim-0.11.21.tgz","fileCount":42,"integrity":"sha512-OAJZQRqb9aYUl5AKTakPuQz364IUsfAHg41TC460osbw9a9rCiM6ffhoW+7fKcRsElhThk2YFcBOdzWpc9R7VA==","signatures":[{"sig":"MEUCIQD3HPJRxqBIPga0UwDBDIlpoVdj54daazYkIxB8kCRUYAIgLmLRWAB0stufQoGsBhuxmAhXFJjzBNoWNYCwgmHZZ20=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":72458,"size":16687,"noattachment":false,"key":"/spacetrim/-/spacetrim-0.11.21.tgz"},"main":"./dist/umd/index.js","module":"./dist/esm/index.js","gitHead":"78308a5e151644e12f7bb6546d3e75b066e18589","private":false,"scripts":{"lint":"tslint -p tsconfig.json","test":"jest","build":"rm -rf ./dist && rollup --config rollup.config.ts","preversion":"npm run lint && npm test","postversion":"git push && git push --tags"},"typings":"./dist/esm/typings/index.d.ts","_npmUser":{"name":"hejny","email":"pavol@hejny.org"},"repository":{"url":"git+https://github.com/hejny/spacetrim.git","type":"git"},"_npmVersion":"8.11.0","description":"Spacetrim is trimming string from all 4 sides.","directories":{},"sideEffects":false,"_nodeVersion":"17.9.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"27.3.1","tslib":"2.3.1","rollup":"2.58.1","tslint":"6.1.3","ts-jest":"27.0.7","typescript":"4.4.4","@types/jest":"27.0.2","tslint-config-prettier":"1.18.0","@rollup/plugin-typescript":"8.3.0"},"_npmOperationalInternal":{"tmp":"tmp/spacetrim_0.11.21_1714054904475_0.6135505152723997","host":"s3://npm-registry-packages"},"readme":"# ✂️ Space trim\n\n<!--Badges-->\n<!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src/workflows/800-badges/badges.ts so every manual change will be overwritten.-->\n\n\n[![License of Space trim](https://img.shields.io/github/license/hejny/spacetrim.svg?style=flat)](https://github.com/hejny/spacetrim/blob/main/LICENSE)\n[![NPM Version of Space trim](https://badge.fury.io/js/spacetrim.svg)](https://www.npmjs.com/package/spacetrim)\n[![Quality of package Space trim](https://packagequality.com/shield/spacetrim.svg)](https://packagequality.com/#?package=spacetrim)\n[![lint](https://github.com/hejny/spacetrim/actions/workflows/lint.yml/badge.svg)](https://github.com/hejny/spacetrim/actions/workflows/lint.yml)\n[![test](https://github.com/hejny/spacetrim/actions/workflows/test.yml/badge.svg)](https://github.com/hejny/spacetrim/actions/workflows/test.yml)\n[![Known Vulnerabilities](https://snyk.io/test/github/hejny/spacetrim/badge.svg)](https://snyk.io/test/github/hejny/spacetrim)\n[![Issues](https://img.shields.io/github/issues/hejny/spacetrim.svg?style=flat)](https://github.com/hejny/spacetrim/issues)\n[![Socket](https://socket.dev/api/badge/npm/package/spacetrim)](https://socket.dev/npm/package/spacetrim)\n\n<!--/Badges-->\n\nSpacetrim is trimming string from all 4 sides.\n\nIt is very helpful to keep pretty code indentation without keeping strange spaces inside a string.\n\n<!--Wallpaper-->\n<!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src//workflows/315-ai-generated-wallpaper/4-aiGeneratedWallpaperUseInReadme.ts so every manual change will be overwritten.-->\n\n<!--\n[![Wallpaper of ✂️ Space trim](assets/ai/wallpaper/gallery/425d6259-2bb1-4173-99f8-a19c6b8254a5-0_0.png)](https://www.midjourney.com/app/jobs/425d6259-2bb1-4173-99f8-a19c6b8254a5)\n-->\n\n<!--/Wallpaper-->\n\n> ░ is whitespace and `spaceTrim` will trim the string at the boundaries ╔═╗\n\n```\n░░░░░░░░░░░░░\n░░░░░░░░░░░░░░\n░░░░░░░╔═════╗░\n░░░░░░░║Hello║░░\n░░░░░░░║Space║░░░\n░░░░░░░║Trim ║░░░░\n░░░░░░░╚═════╝░░░░░\n░░░░░░░░░░░░░░░░░░░░\n```\n\n## Usage\n\n```bash\nnpm i spacetrim\n```\n\n```typescript\nimport spaceTrim from 'spacetrim';\n\nconst trimmed = spaceTrim(`\n\n    Hello\n    Space\n    Trim\n\n\n`);\n\nconsole.log(trimmed);\n\n/*\nHello\nSpace\nTrim\n*/\n```\n\n_See more examples in [simple tests](./src/spaceTrim.test.ts)._\n\n## Nesting\n\nThis is very usefull when you want to trim multiline strings inside multiline strings.\n\n```typescript\nimport { spaceTrim } from 'spacetrim';\n\nconst trimmed = spaceTrim(\n    (block) => `\n\n        Numbers\n            ${block(['1', '2', '3'].join('\\n'))}\n        Chars\n            ${block(['A', 'B', 'C'].join('\\n'))}\n\n`,\n);\n\nconsole.log(trimmed);\n\n/*\nNumbers\n    1\n    2\n    3\nChars\n    A\n    B\n    C\n*/\n```\n\n_See more examples in [nesting tests](./src/nesting/nesting.test.ts)._\n\n## Asynchronous nesting\n\nYou can also trim multiline strings which are fetched asynchronously inside multiline strings.\n\n```typescript\nimport { spaceTrim } from 'spacetrim';\n\nconst trimmed = await spaceTrim(\n    async (block) => `\n\n        TypeScript:\n            ${await fetch('https://en.wikipedia.org/wiki/TypeScript').then(\n                (result) => result.text(),\n            )}\n\n\n`,\n);\n\nconsole.log(trimmed);\n\n/*\nTypeScript:\n    TypeScript is a free and open source programming language...\n*/\n```\n\n_See more examples in [asynchronous nesting tests](./src/nesting/async-nesting.test.ts)._\n\n<!--Contributing-->\n<!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src/workflows/810-contributing/contributing.ts so every manual change will be overwritten.-->\n\n## 🖋️ Contributing\n\nI am open to pull requests, feedback, and suggestions. Or if you like this utility, you can [☕ buy me a coffee](https://www.buymeacoffee.com/hejny) or [donate via cryptocurrencies](https://github.com/hejny/hejny/blob/main/documents/crypto.md).\n\nYou can also ⭐ star the spacetrim package, [follow me on GitHub](https://github.com/hejny) or [various other social networks](https://www.pavolhejny.com/contact/).\n\n<!--/Contributing-->\n\n<!--Partners-->\n<!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src/workflows/820-partners/partners.ts so every manual change will be overwritten.-->\n\n## ✨ Partners\n\n\n<a href=\"https://collboard.com/\" title=\"Collboard\"><img src=\"https://collboard.fra1.cdn.digitaloceanspaces.com/assets/18.12.1/logo-small.png#gh-light-mode-only\" alt=\"Collboard\" height=\"60\"/></a>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n<a href=\"https://webgpt.cz/?partner=ph&utm_medium=referral&utm_source=github-readme&utm_campaign=partner-ph\" title=\"WebGPT\"><img src=\"https://webgpt.cz/_next/static/media/webgpt-black.8d958d25.png#gh-light-mode-only\" alt=\"WebGPT\" height=\"60\"/></a>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n<a href=\"https://github.com/webgptorg/promptbook\" title=\"Promptbook\"><img src=\"https://raw.githubusercontent.com/webgptorg/promptbook/main/other/design/logo.png#gh-light-mode-only\" alt=\"Promptbook\" height=\"60\"/></a>\n\n\n[Become a partner](https://www.pavolhejny.com/contact/)\n\n<!--/Partners-->\n","publish_time":1714054904656,"maintainers":[{"name":"hejny","email":"pavol@hejny.org"}],"_cnpm_publish_time":1714054904656,"dist-tags":{"latest":"0.13.0"}}