Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spacetrim

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spacetrim

Trimming string from all 4 sides

  • 0.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
477K
increased by0.49%
Maintainers
1
Weekly downloads
 
Created
Source

✂️ 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

FAQs

Package last updated on 02 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc