-
Notifications
You must be signed in to change notification settings - Fork 0
Glad.string
Assume string === Glad.string for the examples below.
-
color
- Produces a colorized string for stdout.
string.color('Oh No', 'red') - Can be any color name supported by chalk.js
- Produces a colorized string for stdout.
-
deburr
- converts unicode
string.deburr('♥') === 'love'-
converts short symbols
string.deburr('<3') === 'love'string.deburr('released w/ stuff') === 'released with stuff'string.deburr('live && loud') === live and loud'string.deburr(':) || sad') === 'smile or sad' -
converts Latin characters
string.deburr('À') === 'A'See fig s1 at the bottom of the page for a list of all supported characters -
converts Greek characters
string.deburr('α') === 'a'See fig s2 at the bottom of the page for a list of all supported characters -
converts Turkish characters
string.deburr('ş') === 's'See fig s3 at the bottom of the page for a list of all supported characters -
converts Russian characters
string.deburr('ф') === 'f'See fig s4 at the bottom of the page for a list of all supported characters
-
slugify
Creates a normalized slug from a string
string.slugify('San Francisco, CA') === 'san-francisco-ca'string.slugify('The brown fox w/ βeta') === 'the-brown-fox-with-beta'string.slugify('good news so you can :)') === 'good-news-so-you-can-smile'If you need to create a multi-variable slug such as
first_name + " " + last_nameetc... consider allowing slugify to do the concatenation for you.slugifycan receive "n" arguments which become concatenated to form additional segments of the slug.string.slugify('how to create stuff', 'June 17 2017') === 'how-to-create-stuff-june-17-2017' -
camelize
string.camelize("fooze-barz") === 'foozeBarz' -
titleize
string.titelize("fooze barz") === 'Fooze Barz' -
slasherize
string.slasherize("fooze barz") === "fooze/barz" -
reverseSlasherize
string.reverseSlasherize("fooze barz") === "barz/fooze" -
underscore
string.underscore("fooze barz") === "fooze_barz" -
cleanSpaces
`string.cleanSpaces("fooze barz") === "fooze barz"
-
endsWith
string.endsWith("fooze barz fooze", "fooze") === truestring.endsWith("fooze barz", "fooze") === false -
escape
`string.escape("fred, barney, & pebbles") === "fred, barney, & pebbles"
-
unescape
string.unescape("fred, barney, & pebbles") === "fred, barney, & pebbles" -
escapeRegExp
escapes a string for use in regexp
string.escapeRegExp('[lodash](https://lodash.com/)') === "\\[lodash\\]\\(https://lodash\\.com/\\)" -
repeat
string.repeat("glad", 2) === "gladglad" -
startsWith
string.startsWith("fooze barz", "fooze") === truestring.startsWith("x fooze barz", "fooze") === false -
words
split a string based on words
string.words('fred, barney, & pebbles') === ['fred', 'barney', 'pebbles']split a string based on words and keep elements by regexp
string.words('fred, barney, & pebbles', /[^, ]+/g) === ['fred', 'barney', '&', 'pebbles'] -
sentenceCase
Capitalizes letters at the beginning of a string, and after periods.
fig s1 - Supported Latin Chars
'À' => 'A'
'Á' => 'A'
'Â' => 'A'
'Ã' => 'A'
'Ä' => 'A'
'Å' => 'A'
'Æ' => 'Ae'
'Ç' => 'C'
'È' => 'E'
'É' => 'E'
'Ê' => 'E'
'Ë' => 'E'
'Ì' => 'I'
'Í' => 'I'
'Î' => 'I'
'Ï' => 'I'
'Ð' => 'D'
'Ñ' => 'N'
'Ò' => 'O'
'Ó' => 'O'
'Ô' => 'O'
'Õ' => 'O'
'Ö' => 'O'
'Ő' => 'O'
'Ø' => 'O'
'Ù' => 'U'
'Ú' => 'U'
'Û' => 'U'
'Ü' => 'U'
'Ű' => 'U'
'Ý' => 'Y'
'Þ' => 'Th'
'ß' => 'ss'
'à' => 'a'
'á' => 'a',
'â' => 'a'
'ã' => 'a'
'ä' => 'a'
'å' => 'a'
'æ' => 'ae'
'ç' => 'c'
'è' => 'e',
'é' => 'e'
'ê' => 'e'
'ë' => 'e'
'ì' => 'i'
'í' => 'i'
'î' => 'i'
'ï' => 'i'
'ð' => 'd'
'ñ' => 'n'
'ò' => 'o'
'ó' => 'o'
'ô' => 'o'
'õ' => 'o'
'ö' => 'o'
'ő' => 'o'
'ø' => 'o'
'ù' => 'u'
'ú' => 'u'
'û' => 'u'
'ü' => 'u'
'ű' => 'u'
'ý' => 'y'
'þ' => 'th'
'ÿ' => 'y'
fig s2 Greek character conversion
'α' => 'a'
'β' => 'b'
'γ' => 'g'
'δ' => 'd'
'ε' => 'e'
'ζ' => 'z'
'η' => 'h'
'θ' => '8'
'ι' => 'i'
'κ' => 'k'
'λ' => 'l'
'μ' => 'm'
'ν' => 'n'
'ξ' => '3'
'ο' => 'o'
'π' => 'p'
'ρ' => 'r'
'σ' => 's'
'τ' => 't'
'υ' => 'y'
'φ' => 'f'
'χ' => 'x'
'ψ' => 'ps'
'ω' => 'w'
'ά' => 'a'
'έ' => 'e'
'ί' => 'i'
'ό' => 'o'
'ύ' => 'y'
'ή' => 'h'
'ώ' => 'w'
'ς' => 's'
'ϊ' => 'i'
'ΰ' => 'y'
'ϋ' => 'y'
'ΐ' => 'i'
'Α' => 'A'
'Β' => 'B'
'Γ' => 'G'
'Δ' => 'D'
'Ε' => 'E'
'Ζ' => 'Z'
'Η' => 'H'
'Θ' => '8'
'Ι' => 'I'
'Κ' => 'K'
'Λ' => 'L'
'Μ' => 'M'
'Ν' => 'N'
'Ξ' => '3'
'Ο' => 'O'
'Π' => 'P'
'Ρ' => 'R'
'Σ' => 'S'
'Τ' => 'T'
'Υ' => 'Y'
'Φ' => 'F'
'Χ' => 'X'
'Ψ' => 'PS'
'Ω' => 'W'
'Ά' => 'A'
'Έ' => 'E'
'Ί' => 'I'
'Ό' => 'O'
'Ύ' => 'Y'
'Ή' => 'H'
'Ώ' => 'W'
'Ϊ' => 'I'
'Ϋ' => 'Y
fig s3 Turkish character conversion
'ş' => 's'
'Ş' => 'S'
'ı' => 'i'
'İ' => 'I'
'ğ' => 'g'
'Ğ' => 'G'
fig s4 Russian character conversion
'а' => 'a'
'б' => 'b'
'в' => 'v'
'г' => 'g'
'д' => 'd'
'е' => 'e'
'ё' => 'yo'
'ж' => 'zh'
'з' => 'z'
'и' => 'i'
'й' => 'j'
'к' => 'k'
'л' => 'l'
'м' => 'm'
'н' => 'n'
'о' => 'o'
'п' => 'p'
'р' => 'r'
'с' => 's'
'т' => 't'
'у' => 'u'
'ф' => 'f'
'х' => 'h'
'ц' => 'c',
'ч' => 'ch'
'ш' => 'sh'
'щ' => 'sh'
'ъ' => 'u'
'ы' => 'y'
'э' => 'e'
'ю' => 'yu'
'я' => 'ya'
'А' => 'A'
'Б' => 'B'
'В' => 'V'
'Г' => 'G'
'Д' => 'D'
'Е' => 'E'
'Ё' => 'Yo'
'Ж' => 'Zh'
'З' => 'Z'
'И' => 'I'
'Й' => 'J'
'К' => 'K'
'Л' => 'L'
'М' => 'M'
'Н' => 'N'
'О' => 'O'
'П' => 'P'
'Р' => 'R'
'С' => 'S'
'Т' => 'T'
'У' => 'U'
'Ф' => 'F'
'Х' => 'H'
'Ц' => 'C'
'Ч' => 'Ch'
'Ш' => 'Sh'
'Щ' => 'Sh'
'Ъ' => 'U'
'Ы' => 'Y'
'Ь' => 'Ь'
'Э' => 'E'
'Ю' => 'Yu'
'Я' => 'Ya'