Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
spacetrim
Advanced tools
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.
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.
░░░░░░░░░░░░░
░░░░░░░░░░░░░░
░░░░░░░╔═════╗░
░░░░░░░║Hello║░░
░░░░░░░║Space║░░░
░░░░░░░║Trim ║░░░░
░░░░░░░╚═════╝░░░░░
░░░░░░░░░░░░░░░░░░░░
npm i spacetrim
import { spaceTrim } from 'spacetrim';
const trimmed = spaceTrim(`
Hello
Space
Trim
`);
console.log(trimmed);
/*
Hello
Space
Trim
*/
See more examples in simple tests.
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.
You can also trim multiline strings which are fetched asynchronously inside multiline strings.
import { spaceTrim } from 'spacetrim';
const trimmed = await spaceTrim(
async (block) => `
TypeScript:
${await fetch('https://en.wikipedia.org/wiki/TypeScript').then(
(result) => result.text(),
)}
`,
);
console.log(trimmed);
/*
TypeScript:
TypeScript is a free and open source programming language...
*/
See more examples in asynchronous nesting tests.
I am open to pull requests, feedback, and suggestions. Or if you like this utility, you can ☕ buy me a coffee or donate via cryptocurrencies.
You can also ⭐ star the spacetrim package, follow me on GitHub or various other social networks.
FAQs
Spacetrim is trimming string from all 4 sides.
The npm package spacetrim receives a total of 403,341 weekly downloads. As such, spacetrim popularity was classified as popular.
We found that spacetrim demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.