JSPM

  • Created
  • Published
  • Downloads 833889
  • Score
    100M100P100Q221014F
  • License SEE LICENSE IN LICENSE

Trimming string from all 4 sides

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

License of ✂️ Space trim NPM Version of ✂️ Space trim Quality of package ✂️ Space trim lint test Known Vulnerabilities Issues

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

Collboard logo     Czech.events logo     SigmaStamp logo

Become a partner