{"id":16202779,"url":"https://github.com/hejny/spacetrim","last_synced_at":"2025-04-30T10:05:44.303Z","repository":{"id":55341465,"uuid":"419477416","full_name":"hejny/spacetrim","owner":"hejny","description":"Spacetrim is trimming string from all 4 sides. It is very helpful to keep pretty code indentation without keeping a strange spaces inside a strings.","archived":false,"fork":false,"pushed_at":"2024-06-26T20:15:31.000Z","size":86905,"stargazers_count":10,"open_issues_count":1,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-03T14:51:45.423Z","etag":null,"topics":["javascript","library","nodejs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hejny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-20T20:17:14.000Z","updated_at":"2024-08-11T11:41:12.423Z","dependencies_parsed_at":"2023-02-12T17:15:56.956Z","dependency_job_id":"e01ed9fc-2f35-4986-b5cd-acb87f474e68","html_url":"https://github.com/hejny/spacetrim","commit_stats":{"total_commits":201,"total_committers":2,"mean_commits":100.5,"dds":0.00497512437810943,"last_synced_commit":"e47a89c31af49228616fa81b34ccfe532aa10ffb"},"previous_names":[],"tags_count":103,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hejny%2Fspacetrim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hejny%2Fspacetrim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hejny%2Fspacetrim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hejny%2Fspacetrim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hejny","download_url":"https://codeload.github.com/hejny/spacetrim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":231370914,"owners_count":18366433,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","library","nodejs","typescript"],"created_at":"2024-10-10T09:49:12.706Z","updated_at":"2024-12-26T15:10:30.928Z","avatar_url":"https://github.com/hejny.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/hejny"],"categories":[],"sub_categories":[],"readme":"# ✂️ Space trim\n\n\u003c!--Badges--\u003e\n\u003c!--⚠️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.--\u003e\n\n\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\u003c!--[![License of Space trim](https://img.shields.io/github/license/hejny/spacetrim.svg?style=flat)](https://github.com/hejny/spacetrim/blob/main/LICENSE)--\u003e\n\n\u003c!--/Badges--\u003e\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\u003c!--Wallpaper--\u003e\n\u003c!--⚠️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.--\u003e\n\n\u003c!--\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--\u003e\n\n\u003c!--/Wallpaper--\u003e\n\n\u003e ░ 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) =\u003e `\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) =\u003e `\n\n        TypeScript:\n            ${await fetch('https://en.wikipedia.org/wiki/TypeScript').then(\n                (result) =\u003e 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\u003c!--Contributing--\u003e\n\u003c!--⚠️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.--\u003e\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\u003c!--/Contributing--\u003e\n\n\u003c!--Partners--\u003e\n\u003c!--⚠️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.--\u003e\n\n## ✨ Partners\n\n\n\u003ca href=\"https://collboard.com/\" title=\"Collboard\"\u003e\u003cimg src=\"https://collboard.fra1.cdn.digitaloceanspaces.com/assets/18.12.1/logo-small.png#gh-light-mode-only\" alt=\"Collboard\" height=\"60\"/\u003e\u003c/a\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003ca href=\"https://webgpt.cz/?partner=ph\u0026utm_medium=referral\u0026utm_source=github-readme\u0026utm_campaign=partner-ph\" title=\"WebGPT\"\u003e\u003cimg src=\"https://webgpt.cz/_next/static/media/webgpt-black.8d958d25.png#gh-light-mode-only\" alt=\"WebGPT\" height=\"60\"/\u003e\u003c/a\u003e\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\n\u003ca href=\"https://github.com/webgptorg/promptbook\" title=\"Promptbook\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/webgptorg/promptbook/main/other/design/logo.png#gh-light-mode-only\" alt=\"Promptbook\" height=\"60\"/\u003e\u003c/a\u003e\n\n\n[Become a partner](https://www.pavolhejny.com/contact/)\n\n\u003c!--/Partners--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhejny%2Fspacetrim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhejny%2Fspacetrim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhejny%2Fspacetrim/lists"}