1 | ;
|
2 | /**
|
3 | * @license
|
4 | * Copyright Google LLC All Rights Reserved.
|
5 | *
|
6 | * Use of this source code is governed by an MIT-style license that can be
|
7 | * found in the LICENSE file at https://angular.io/license
|
8 | */
|
9 | Object.defineProperty(exports, "__esModule", { value: true });
|
10 | exports.levenshtein = exports.capitalize = exports.underscore = exports.classify = exports.camelize = exports.dasherize = exports.decamelize = void 0;
|
11 | const STRING_DASHERIZE_REGEXP = /[ _]/g;
|
12 | const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
13 | const STRING_CAMELIZE_REGEXP = /(-|_|\.|\s)+(.)?/g;
|
14 | const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
|
15 | const STRING_UNDERSCORE_REGEXP_2 = /-|\s+/g;
|
16 | /**
|
17 | * Converts a camelized string into all lower case separated by underscores.
|
18 | *
|
19 | ```javascript
|
20 | decamelize('innerHTML'); // 'inner_html'
|
21 | decamelize('action_name'); // 'action_name'
|
22 | decamelize('css-class-name'); // 'css-class-name'
|
23 | decamelize('my favorite items'); // 'my favorite items'
|
24 | ```
|
25 |
|
26 | @method decamelize
|
27 | @param {String} str The string to decamelize.
|
28 | @return {String} the decamelized string.
|
29 | */
|
30 | function decamelize(str) {
|
31 | return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
|
32 | }
|
33 | exports.decamelize = decamelize;
|
34 | /**
|
35 | Replaces underscores, spaces, or camelCase with dashes.
|
36 |
|
37 | ```javascript
|
38 | dasherize('innerHTML'); // 'inner-html'
|
39 | dasherize('action_name'); // 'action-name'
|
40 | dasherize('css-class-name'); // 'css-class-name'
|
41 | dasherize('my favorite items'); // 'my-favorite-items'
|
42 | ```
|
43 |
|
44 | @method dasherize
|
45 | @param {String} str The string to dasherize.
|
46 | @return {String} the dasherized string.
|
47 | */
|
48 | function dasherize(str) {
|
49 | return decamelize(str).replace(STRING_DASHERIZE_REGEXP, '-');
|
50 | }
|
51 | exports.dasherize = dasherize;
|
52 | /**
|
53 | Returns the lowerCamelCase form of a string.
|
54 |
|
55 | ```javascript
|
56 | camelize('innerHTML'); // 'innerHTML'
|
57 | camelize('action_name'); // 'actionName'
|
58 | camelize('css-class-name'); // 'cssClassName'
|
59 | camelize('my favorite items'); // 'myFavoriteItems'
|
60 | camelize('My Favorite Items'); // 'myFavoriteItems'
|
61 | ```
|
62 |
|
63 | @method camelize
|
64 | @param {String} str The string to camelize.
|
65 | @return {String} the camelized string.
|
66 | */
|
67 | function camelize(str) {
|
68 | return str
|
69 | .replace(STRING_CAMELIZE_REGEXP, (_match, _separator, chr) => {
|
70 | return chr ? chr.toUpperCase() : '';
|
71 | })
|
72 | .replace(/^([A-Z])/, (match) => match.toLowerCase());
|
73 | }
|
74 | exports.camelize = camelize;
|
75 | /**
|
76 | Returns the UpperCamelCase form of a string.
|
77 |
|
78 | @example
|
79 | ```javascript
|
80 | 'innerHTML'.classify(); // 'InnerHTML'
|
81 | 'action_name'.classify(); // 'ActionName'
|
82 | 'css-class-name'.classify(); // 'CssClassName'
|
83 | 'my favorite items'.classify(); // 'MyFavoriteItems'
|
84 | 'app.component'.classify(); // 'AppComponent'
|
85 | ```
|
86 | @method classify
|
87 | @param {String} str the string to classify
|
88 | @return {String} the classified string
|
89 | */
|
90 | function classify(str) {
|
91 | return str
|
92 | .split('.')
|
93 | .map((part) => capitalize(camelize(part)))
|
94 | .join('');
|
95 | }
|
96 | exports.classify = classify;
|
97 | /**
|
98 | More general than decamelize. Returns the lower_case_and_underscored
|
99 | form of a string.
|
100 |
|
101 | ```javascript
|
102 | 'innerHTML'.underscore(); // 'inner_html'
|
103 | 'action_name'.underscore(); // 'action_name'
|
104 | 'css-class-name'.underscore(); // 'css_class_name'
|
105 | 'my favorite items'.underscore(); // 'my_favorite_items'
|
106 | ```
|
107 |
|
108 | @method underscore
|
109 | @param {String} str The string to underscore.
|
110 | @return {String} the underscored string.
|
111 | */
|
112 | function underscore(str) {
|
113 | return str
|
114 | .replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2')
|
115 | .replace(STRING_UNDERSCORE_REGEXP_2, '_')
|
116 | .toLowerCase();
|
117 | }
|
118 | exports.underscore = underscore;
|
119 | /**
|
120 | Returns the Capitalized form of a string
|
121 |
|
122 | ```javascript
|
123 | 'innerHTML'.capitalize() // 'InnerHTML'
|
124 | 'action_name'.capitalize() // 'Action_name'
|
125 | 'css-class-name'.capitalize() // 'Css-class-name'
|
126 | 'my favorite items'.capitalize() // 'My favorite items'
|
127 | ```
|
128 |
|
129 | @method capitalize
|
130 | @param {String} str The string to capitalize.
|
131 | @return {String} The capitalized string.
|
132 | */
|
133 | function capitalize(str) {
|
134 | return str.charAt(0).toUpperCase() + str.slice(1);
|
135 | }
|
136 | exports.capitalize = capitalize;
|
137 | /**
|
138 | * Calculate the levenshtein distance of two strings.
|
139 | * See https://en.wikipedia.org/wiki/Levenshtein_distance.
|
140 | * Based off https://gist.github.com/andrei-m/982927 (for using the faster dynamic programming
|
141 | * version).
|
142 | *
|
143 | * @param a String a.
|
144 | * @param b String b.
|
145 | * @returns A number that represents the distance between the two strings. The greater the number
|
146 | * the more distant the strings are from each others.
|
147 | */
|
148 | function levenshtein(a, b) {
|
149 | if (a.length == 0) {
|
150 | return b.length;
|
151 | }
|
152 | if (b.length == 0) {
|
153 | return a.length;
|
154 | }
|
155 | const matrix = [];
|
156 | // increment along the first column of each row
|
157 | for (let i = 0; i <= b.length; i++) {
|
158 | matrix[i] = [i];
|
159 | }
|
160 | // increment each column in the first row
|
161 | for (let j = 0; j <= a.length; j++) {
|
162 | matrix[0][j] = j;
|
163 | }
|
164 | // Fill in the rest of the matrix
|
165 | for (let i = 1; i <= b.length; i++) {
|
166 | for (let j = 1; j <= a.length; j++) {
|
167 | if (b.charAt(i - 1) == a.charAt(j - 1)) {
|
168 | matrix[i][j] = matrix[i - 1][j - 1];
|
169 | }
|
170 | else {
|
171 | matrix[i][j] = Math.min(matrix[i - 1][j - 1] + 1, // substitution
|
172 | matrix[i][j - 1] + 1, // insertion
|
173 | matrix[i - 1][j] + 1);
|
174 | }
|
175 | }
|
176 | }
|
177 | return matrix[b.length][a.length];
|
178 | }
|
179 | exports.levenshtein = levenshtein;
|
180 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RyaW5ncy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2FuZ3VsYXJfZGV2a2l0L2NvcmUvc3JjL3V0aWxzL3N0cmluZ3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7R0FNRzs7O0FBRUgsTUFBTSx1QkFBdUIsR0FBRyxPQUFPLENBQUM7QUFDeEMsTUFBTSx3QkFBd0IsR0FBRyxtQkFBbUIsQ0FBQztBQUNyRCxNQUFNLHNCQUFzQixHQUFHLG1CQUFtQixDQUFDO0FBQ25ELE1BQU0sMEJBQTBCLEdBQUcsb0JBQW9CLENBQUM7QUFDeEQsTUFBTSwwQkFBMEIsR0FBRyxRQUFRLENBQUM7QUFFNUM7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILFNBQWdCLFVBQVUsQ0FBQyxHQUFXO0lBQ3BDLE9BQU8sR0FBRyxDQUFDLE9BQU8sQ0FBQyx3QkFBd0IsRUFBRSxPQUFPLENBQUMsQ0FBQyxXQUFXLEVBQUUsQ0FBQztBQUN0RSxDQUFDO0FBRkQsZ0NBRUM7QUFFRDs7Ozs7Ozs7Ozs7OztHQWFHO0FBQ0gsU0FBZ0IsU0FBUyxDQUFDLEdBQVc7SUFDbkMsT0FBTyxVQUFVLENBQUMsR0FBRyxDQUFDLENBQUMsT0FBTyxDQUFDLHVCQUF1QixFQUFFLEdBQUcsQ0FBQyxDQUFDO0FBQy9ELENBQUM7QUFGRCw4QkFFQztBQUVEOzs7Ozs7Ozs7Ozs7OztHQWNHO0FBQ0g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