{"name":"spacetrim","version":"0.4.2","keywords":[],"author":"","license":"ISC","_id":"spacetrim@0.4.2","homepage":"https://github.com/hejny/spacetrim#readme","bugs":{"url":"https://github.com/hejny/spacetrim/issues"},"dist":{"shasum":"0e5cf3a5e686a17e227dbdef9fe49d1e9fa69953","tarball":"http://registry-npm.ywwl.com/spacetrim/download/spacetrim-0.4.2.tgz","fileCount":13,"integrity":"sha512-J6D8p5gxYk2n9wOi8yG8bligyzy89mQcUgL+A+p+yB2UQkl/yoSTUHjy+Exi1kdwE9c7tnMMsogB2sooYRX5Sg==","signatures":[{"sig":"MEUCIFnzOCmisa+32dpChNiHEBuFSbscJwWW4A7M1bosyCltAiEAkSRWVeYvm/p/qM0XwI+PAvtLpPQOEDer51Z/4DPRTsM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6560,"size":2784,"noattachment":false,"key":"/spacetrim/-/spacetrim-0.4.2.tgz"},"main":"./dist/spaceTrim.js","gitHead":"22d161ecd586bc845d7e243d3ad2176ef057ca91","scripts":{"test":"jest","build":"rollup --config rollup.config.ts","postversion":"git push && git push --tags"},"_npmUser":{"name":"hejny","email":"me@pavolhejny.com"},"repository":{"url":"git+https://github.com/hejny/spacetrim.git","type":"git"},"_npmVersion":"6.14.15","description":"Trimming string from all 4 sides","directories":{},"sideEffects":false,"_nodeVersion":"14.18.1","dependencies":{},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.3.1","tslib":"^2.3.1","rollup":"^2.58.1","ts-jest":"^27.0.7","typescript":"^4.4.4","@types/jest":"^27.0.2","@rollup/plugin-typescript":"^8.3.0"},"_npmOperationalInternal":{"tmp":"tmp/spacetrim_0.4.2_1636545235499_0.5547368836807383","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":1636545235676,"maintainers":[{"name":"hejny","email":"pavol@hejny.org"}],"_cnpm_publish_time":1636545235676,"dist-tags":{"latest":"0.13.0"}}