Package Exports
- spacetrim
- spacetrim/dist/esm/spaceTrim.js
- spacetrim/dist/umd/spaceTrim.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spacetrim) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
✂️ Space trim
Spacetrim is trimming string from all 4 sides.
It is very helpfull to keep pretty code indentation without keeping strange spaces inside strings.
░░░░░░░░░░░░░
░░░░░░░░░░░░░░
░░░░░░░╔═════╗░
░░░░░░░║Hello║░░
░░░░░░░║Space║░░░
░░░░░░░║Trim ║░░░░
░░░░░░░╚═════╝░░░░░
░░░░░░░░░░░░░░░░░░░░
Usage
npm i spacetrim
import { spaceTrim } from 'spacetrim';
const trimmed = spaceTrim(`
Hello
Space
Trim
`);
console.log(trimmed);
/*Hello
Space
Trim*/
See more examples in simple spaceTrim tests.
Nesting
This is very usefull when you want to trim multiline strings inside multiline strings.
import { spaceTrim } from 'spacetrim';
const trimmed = spaceTrim(
(block) => `
Numbers
${block(['1', '2', '3'].join('\n'))}
Chars
${block(['A', 'B', 'C'].join('\n'))}
`,
);
console.log(trimmed);
/*Numbers
1
2
3
Chars
A
B
C*/
See more examples in nesting tests.
🖋️ Contributing
I am opened to pull requests, feedback and suggestions. Or if you like this utility, you can ☕ buy me a coffee or donate via cryptocurrencies
✨ Partners

