String

Useful String methods.



__.string.camelcase( string: string )

Converts underscored or dasherized string to a camelized one. Begins with a lower case letter unless it starts with an underscore, dash or an upper case letter.

__.string.camelcase('-webkit-transition'); // WebkitTransition

__.string.count( string: string, character(s): string, caseInsensitive: boolean )

Returns the number of occurrences of substring in string. By default, it is case sensitive. If you want your query to be case insensitive, you just have to set it as true.

__.string.count('DC Comics', 'C'); // 2
__.string.count('DC Comics', 'c', true); // 3

__.string.md5( string: string )

Converts a string in a MD5 hash. The MD5 (Message-Digest algorithm 5) is a widely used cryptographic hash function producing a 128-bit (16-byte) hash value, commonly used to verify data integrity.

As a unidirectional algorithm, a MD5 hash cannot be converted back to its original form. The verification is done by comparing two hashes.

__.string.md5('secret'); // "5ebe2294ecd0e0f08eab7690d2a6ee69"

__.string.quote( string: string, quoteChar: string )

Quotes a string. Defaults quote character is ". But you can change it.

__.string.quote('Light'); // "Light"

__.string.reverse( string: string )

Return a reversed string.

__.string.reverse('Batman'); // namtaB

__.string.serialize( data: object )

Converts a data object to string.

__.string.serialize({ batman: 'hero' }); // batman=hero

__.string.slugfy( string: string )

Converts a string to slug.

__.string.slugfy('It\'s over now, Thor. I have your Mjölnir!'); // it-s-over-now

__.string.swapcase( string: string )

Swaps all the case-based characters of the string.

__.string.swapcase('DC Comics'); // dc cOMICS

__.string.surround( string: string, character(s): string )

Surrounds a string with another string.

__.string.surround('hello', '--'); // --hello--

__.string.unquote( string: string )

Unquotes a string. You don't need to specify a character. It will check for both.

__.string.unquote('"Light"'); // Light