UNPKG

3.59 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8/**
9 * Converts a camelized string into all lower case separated by underscores.
10 *
11 ```javascript
12 decamelize('innerHTML'); // 'inner_html'
13 decamelize('action_name'); // 'action_name'
14 decamelize('css-class-name'); // 'css-class-name'
15 decamelize('my favorite items'); // 'my favorite items'
16 ```
17
18 @method decamelize
19 @param {String} str The string to decamelize.
20 @return {String} the decamelized string.
21 */
22export declare function decamelize(str: string): string;
23/**
24 Replaces underscores, spaces, or camelCase with dashes.
25
26 ```javascript
27 dasherize('innerHTML'); // 'inner-html'
28 dasherize('action_name'); // 'action-name'
29 dasherize('css-class-name'); // 'css-class-name'
30 dasherize('my favorite items'); // 'my-favorite-items'
31 ```
32
33 @method dasherize
34 @param {String} str The string to dasherize.
35 @return {String} the dasherized string.
36 */
37export declare function dasherize(str: string): string;
38/**
39 Returns the lowerCamelCase form of a string.
40
41 ```javascript
42 camelize('innerHTML'); // 'innerHTML'
43 camelize('action_name'); // 'actionName'
44 camelize('css-class-name'); // 'cssClassName'
45 camelize('my favorite items'); // 'myFavoriteItems'
46 camelize('My Favorite Items'); // 'myFavoriteItems'
47 ```
48
49 @method camelize
50 @param {String} str The string to camelize.
51 @return {String} the camelized string.
52 */
53export declare function camelize(str: string): string;
54/**
55 Returns the UpperCamelCase form of a string.
56
57 @example
58 ```javascript
59 'innerHTML'.classify(); // 'InnerHTML'
60 'action_name'.classify(); // 'ActionName'
61 'css-class-name'.classify(); // 'CssClassName'
62 'my favorite items'.classify(); // 'MyFavoriteItems'
63 'app.component'.classify(); // 'AppComponent'
64 ```
65 @method classify
66 @param {String} str the string to classify
67 @return {String} the classified string
68 */
69export declare function classify(str: string): string;
70/**
71 More general than decamelize. Returns the lower_case_and_underscored
72 form of a string.
73
74 ```javascript
75 'innerHTML'.underscore(); // 'inner_html'
76 'action_name'.underscore(); // 'action_name'
77 'css-class-name'.underscore(); // 'css_class_name'
78 'my favorite items'.underscore(); // 'my_favorite_items'
79 ```
80
81 @method underscore
82 @param {String} str The string to underscore.
83 @return {String} the underscored string.
84 */
85export declare function underscore(str: string): string;
86/**
87 Returns the Capitalized form of a string
88
89 ```javascript
90 'innerHTML'.capitalize() // 'InnerHTML'
91 'action_name'.capitalize() // 'Action_name'
92 'css-class-name'.capitalize() // 'Css-class-name'
93 'my favorite items'.capitalize() // 'My favorite items'
94 ```
95
96 @method capitalize
97 @param {String} str The string to capitalize.
98 @return {String} The capitalized string.
99 */
100export declare function capitalize(str: string): string;
101/**
102 * Calculate the levenshtein distance of two strings.
103 * See https://en.wikipedia.org/wiki/Levenshtein_distance.
104 * Based off https://gist.github.com/andrei-m/982927 (for using the faster dynamic programming
105 * version).
106 *
107 * @param a String a.
108 * @param b String b.
109 * @returns A number that represents the distance between the two strings. The greater the number
110 * the more distant the strings are from each others.
111 */
112export declare function levenshtein(a: string, b: string): number;