@netgrif/components-core
Version:
Netgrif Application engine frontend core Angular library
94 lines (93 loc) • 3.33 kB
TypeScript
/**
* Converts a camelized string into all lower case separated by underscores.
*
* ```javascript
* decamelize('innerHTML'); // 'inner_html'
* decamelize('action_name'); // 'action_name'
* decamelize('css-class-name'); // 'css-class-name'
* decamelize('my favorite items'); // 'my favorite items'
* ```
* @method decamelize
* @param str The string to decamelize.
* @return the decamelized string.
*/
export declare function decamelize(str: string): string;
/**
* Replaces underscores, spaces, or camelCase with dashes.
* ```javascript
* dasherize('innerHTML'); // 'inner-html'
* dasherize('action_name'); // 'action-name'
* dasherize('css-class-name'); // 'css-class-name'
* dasherize('my favorite items'); // 'my-favorite-items'
* ```
* @method dasherize
* @param str The string to dasherize.
* @return the dasherized string.
*/
export declare function dasherize(str: string): string;
/**
* Returns the lowerCamelCase form of a string.
* ```javascript
* camelize('innerHTML'); // 'innerHTML'
* camelize('action_name'); // 'actionName'
* camelize('css-class-name'); // 'cssClassName'
* camelize('my favorite items'); // 'myFavoriteItems'
* camelize('My Favorite Items'); // 'myFavoriteItems'
* ```
* @method camelize
* @param str The string to camelize.
* @return the camelized string.
*/
export declare function camelize(str: string): string;
/**
* Returns the UpperCamelCase form of a string.
* ```javascript
* 'innerHTML'.classify(); // 'InnerHTML'
* 'action_name'.classify(); // 'ActionName'
* 'css-class-name'.classify(); // 'CssClassName'
* 'my favorite items'.classify(); // 'MyFavoriteItems'
* ```
* @method classify
* @param str the string to classify
* @return the classified string
*/
export declare function classify(str: string): string;
/**
* More general than decamelize. Returns the lower\_case\_and\_underscored
* form of a string.
* ```javascript
* 'innerHTML'.underscore(); // 'inner_html'
* 'action_name'.underscore(); // 'action_name'
* 'css-class-name'.underscore(); // 'css_class_name'
* 'my favorite items'.underscore(); // 'my_favorite_items'
* ```
* @method underscore
* @param str The string to underscore.
* @return the underscored string.
*/
export declare function underscore(str: string): string;
/**
* Returns the Capitalized form of a string
* ```javascript
* 'innerHTML'.capitalize() // 'InnerHTML'
* 'action_name'.capitalize() // 'Action_name'
* 'css-class-name'.capitalize() // 'Css-class-name'
* 'my favorite items'.capitalize() // 'My favorite items'
* ```
* @method capitalize
* @param str The string to capitalize.
* @return The capitalized string.
*/
export declare function capitalize(str: string): string;
/**
* Calculate the levenshtein distance of two strings.
* See https://en.wikipedia.org/wiki/Levenshtein_distance.
* Based off https://gist.github.com/andrei-m/982927 (for using the faster dynamic programming
* version).
*
* @param a String a.
* @param b String b.
* @returns A number that represents the distance between the two strings. The greater the number
* the more distant the strings are from each others.
*/
export declare function levenshtein(a: string, b: string): number;