1.0.4 • Published 2 years ago

@theinternetfolks/mate v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

The Internet Folks Logo

Mate

Library for most frequent helper methods for Javascript.

Installation

Install with npm

  npm install @theinternetfolks/mate

Install with yarn

  yarn add @theinternetfolks/mate

Usage/Examples

Format String

You can use it to replace template variables in a string, without the use of Javascript's template literals.

By default the separtor is {}.

Mate.format("Hello {name}", { name:"Dolores" })
// "Hello Dolores"

You could pass the separator, and it would determine it.

Mate.format("Hello {{name}}", { name:"Dolores" }, "{{}}")
// "Hello Dolores"

You can even pass numbers in, for formatting.

Mate.format("Hi, my name is {name} and I am {age} years old.", { name: "Dolores", age: 24000 }, "{}")
"Hi, my name is Dolores and I am 24000 years old."

You could explicitly pass the start and end separator, if you're creative.

Mate.format("Hi, my name is {##name}}.", { name: "Dolores" }, "{##", "}}")
"Hi, my name is Dolores."
Mate.format("Hi, my name is {#name#}.", { name: "Dolores" }, "{#", "#}")
"Hi, my name is Dolores."

To Case

const { Mate } = require("@theinternetfolks/mate");

Mate.toCamel("the_internet_folks");         // "theInternetFolks"
Mate.toCapital("the internet folks");       // "The Internet Folks"
Mate.toConstant("theInternetFolks");        // "THE_INTERNET_FOLKS"
Mate.toDot("theInternetFolks");             // "the.internet.folks"
Mate.toInverse("thE inTerNEt fOLks");       // "THe INtERneT FolKS"
Mate.toLower("theInternetFolks");           // "the internet folks"
Mate.toPascal("the.internet.folks");        // "TheInternetFolks"
Mate.toSentence("THE INTERNET FOLKS.");     // "The internet folks."
Mate.toSlug("theInternetFolks");            // "the-internet-folks"
Mate.toSnake("theInternetFolks");           // "the_internet_folks"
Mate.toSpace("the.internet.folks");         // "the internet folks"
Mate.toTitle("the internet folks");         // "The Internet Folks"
Mate.toUpper("theInternetFolks");           // "THE INTERNET FOLKS"

Test Coverage

Support

For support, email hi at theinternetfolks.com.

License

MIT

Thanks to to-case for providing a necessary starting point for this repo.