0.7.5 • Published 2 years ago

strand-ts v0.7.5

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

strand_logo

What is Strand?

Strand is a collection of string utility methods built in Typescript that makes converting strings a breeze.

How to install

With NPM use

npm install strand-ts

Or Yarn

yarn add strand-ts

How to use

There are two ways of using strand, either by a single method or using the 'chain' method to string together as many methods as you'd like.

The chain method

import { chain } from 'strand-ts';

const string1 = chain('Some random String').snakeCase().get().toLowerCase();
// 'some_random_string'

const string2 = chain('SOME RANDOM STRING').titleCase().kebabCase().get()
// 'Some-Random-String'

Chaining methods like this is meant to be similar to using the javascript string prototype chain without needing to extend it directly. You can chain as many methods as you'd like to the original string and when you're done just call the get() method to return your newly formatted string. Afterwards you're free to add any native string methods to it.

Single methods

import { snakeCase, titleCase } from 'strand-ts';

const string1 = snakeCase('Some random String').toLowerCase();
// 'some_random_string'

const string2 = titleCase('SOME RANDOM STRING');
// 'Some Random String'

Available Methods

MethodDescription
camelCasecamelCase
kebabCasekebab-case
limitCharslimits the number of characters in a string
limitWordslimits the number of words in a string
pascalCasePascalCase
removeWhitespacetrims excess whitespace from entire string
revertCamelCasecamelCase -> camel case
revertKebabCasekebab-case -> kebab case
revertPascalCasePascalCase -> Pascal Case
revertSnakeCasesnake_case -> snake case
snakeCasesnake_case
titleCaseTitle Case
0.7.5

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.7.2

3 years ago

0.7.1

3 years ago