2.0.3 • Published 5 years ago

help-my-strings v2.0.3

Weekly downloads
192
License
ISC
Repository
github
Last release
5 years ago

CircleCI

logo

Capitalize

returns a string with only the first letter capitalized

capitalize("hello world") // => Hello world
capitalize("HellO WOrLd") // => Hello world
capitalize("HELLOWORLD") // => Helloworld

Humanize

returns a string suitable for human consumption

humanize("hello_world") // => hello world
humanize("RenderHtml") // => Render Html
humanize("HTMLRender") // => HTML Render

Titalize

returns a string in title format

titalize("hello world") // => Hello World
titalize("hello_world") // => Hello World
titalize("HelloWorld") // => Hello World

Truncate

returns a truncated string

truncate(string, {omission?, length?, separator?})

OptionPurposedefault
omissionReplaces the truncated content...
lengthThe total length of the truncated content, including omission characters20
separatorDefines the separator between words. Will stop at the last seperator if a word is broken by truncationundefined
truncate("Hello my name is James") // => Hello my name is ...
truncate("hello my name is James", { omission: "???", length: 10 }) // => Hello m???
truncate("hello my name is James", { length: 10, separator: " " }) // => Hello...
truncate("hello my name is James", { length: 11, separator: " " }) // => Hello my...

CamelCase

returns a string in camel case with option to capitalise first letter

camelCase("hello_world") // => helloWorld
camelCase("hello-world") // => helloWorld
camelCase("hello.world-bear") // => helloWorldBear
camelCase("hello_world", true) // => HelloWorld

Singularize

returns the singular of the word

singularize("words") // => word
singularize("people") // => person
singularize("car") // => car

Pluralize

returns a pluralised word

pluralize("cat") // => cats
pluraliz("person") // => people

pluralize(0, "thing") // => 0 things
pluralize(1, "thing") // => 1 thing
pluralize(2, "thing") // => 2 things
pluralize(1, "thing" undefined, { noCount: true }) // => thing
pluralize(2, "thing" undefined, { noCount: true }) // => things

SnakeCase

returns a string in snake case

snakeCase("words are cool") // => words_are_cool
snakeCase("Words-Are-Cool") // => words_are_cool

Parameterize

returns a string in a parameterized form, suitable for URL slugs

parameterize("hello world") // => hello-world
parameterize("hello.world") // => helloworld
parameterize("hello world.bear") // => hello-worldbear
2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.10

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago