trim-margin
Advanced tools
Weekly downloads
Readme
trimMargin
like Kotlin and stripMargin
like Scala.
trimMargin
or stripMargin
.$ npm i -S trim-margin
const {
trimMargin,
tm,
inject,
} = require("trim-margin");
console.log(trimMargin(`
|trim
| indent
| spaces`));
// => "\ntrim\n indent\n spaces"
console.log(trimMargin(`
#other
# delimiter`, "#"));
// => "\nother\n delimiter"
const template = ` | template`;
const literal = ` | literal`;
console.log(tm`\
|tagged
${template}
|${literal}`);
// => "tagged\n template\n | literal"
inject();
console.log(`\
|inject
to | string`.trimMargin());
// => "inject\n to | string"
Trim indent spaces.
More detail "spaces":
Matches a single character other than white space. Equivalent to
[^ \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]
.
From: MDN web docs
Expect, /\r?\n/
Indented string.
Indent delimiter.
This is used as an argument to a RegExp
object.
defalut: "\\|"
Same trimMargin
.
Use as Tagged template literals.
Same trimMargin(literal)
.
Same tm
.
Inject to String
: trimMargin
and stripMargin
.
You can use it like method of string type.
Inject to String
: trimMargin
.
You can use it like method of string type.
Inject to String
: stripMargin
.
You can use it like method of string type.
Inject to String
.
You can use it like method of string type.
Method name injected into string type.
MIT © tee-talog
FAQs
"trimMargin" like Kotlin and "stripMargin" like Scala.
The npm package trim-margin receives a total of 221 weekly downloads. As such, trim-margin popularity was classified as not popular.
We found that trim-margin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.