@ember-data/request-utils 5.4.1-beta.0 → 5.4.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deprecation-support.js +2 -1
- package/dist/deprecation-support.js.map +1 -1
- package/dist/handlers.js +147 -0
- package/dist/handlers.js.map +1 -0
- package/dist/index.js +240 -27
- package/dist/index.js.map +1 -1
- package/dist/{inflect-8aYUyMN7.js → inflect-CwI_k2it.js} +141 -147
- package/dist/inflect-CwI_k2it.js.map +1 -0
- package/dist/string.js +2 -1
- package/dist/string.js.map +1 -1
- package/dist/transform-1PDozfHr.js +192 -0
- package/dist/transform-1PDozfHr.js.map +1 -0
- package/package.json +7 -6
- package/unstable-preview-types/-private/handlers/auto-compress.d.ts +168 -0
- package/unstable-preview-types/-private/handlers/auto-compress.d.ts.map +1 -0
- package/unstable-preview-types/-private/string/inflect.d.ts +126 -0
- package/unstable-preview-types/-private/string/inflect.d.ts.map +1 -1
- package/unstable-preview-types/-private/string/transform.d.ts +93 -57
- package/unstable-preview-types/-private/string/transform.d.ts.map +1 -1
- package/unstable-preview-types/handlers.d.ts +11 -0
- package/unstable-preview-types/handlers.d.ts.map +1 -0
- package/unstable-preview-types/index.d.ts +184 -10
- package/unstable-preview-types/index.d.ts.map +1 -1
- package/unstable-preview-types/string.d.ts +12 -0
- package/unstable-preview-types/string.d.ts.map +1 -1
- package/dist/inflect-8aYUyMN7.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { L as LRUCache, a as capitalize } from "./transform-1PDozfHr.js";
|
|
1
2
|
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
3
|
const defaultRules = {
|
|
3
4
|
plurals: [[/$/, 's'], [/s$/i, 's'], [/^(ax|test)is$/i, '$1es'], [/(octop|vir)us$/i, '$1i'], [/(octop|vir)i$/i, '$1i'], [/(alias|status|bonus)$/i, '$1es'], [/(bu)s$/i, '$1ses'], [/(buffal|tomat)o$/i, '$1oes'], [/([ti])um$/i, '$1a'], [/([ti])a$/i, '$1a'], [/sis$/i, 'ses'], [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'], [/(hive)$/i, '$1s'], [/([^aeiouy]|qu)y$/i, '$1ies'], [/(x|ch|ss|sh)$/i, '$1es'], [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'], [/^(m|l)ouse$/i, '$1ice'], [/^(m|l)ice$/i, '$1ice'], [/^(ox)$/i, '$1en'], [/^(oxen)$/i, '$1'], [/(quiz)$/i, '$1zes']],
|
|
@@ -5,155 +6,11 @@ const defaultRules = {
|
|
|
5
6
|
irregularPairs: [['person', 'people'], ['man', 'men'], ['child', 'children'], ['sex', 'sexes'], ['move', 'moves'], ['cow', 'kine'], ['zombie', 'zombies']],
|
|
6
7
|
uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police']
|
|
7
8
|
};
|
|
8
|
-
const DEFAULT_MAX_CACHE_SIZE = 10_000;
|
|
9
|
-
class LRUCache {
|
|
10
|
-
// debug stats
|
|
11
|
-
|
|
12
|
-
constructor(doWork, size) {
|
|
13
|
-
this.size = size || DEFAULT_MAX_CACHE_SIZE;
|
|
14
|
-
this.state = new Map();
|
|
15
|
-
this.doWork = doWork;
|
|
16
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
17
|
-
this._hits = 0;
|
|
18
|
-
this._misses = 0;
|
|
19
|
-
this._ejected = 0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
get(key) {
|
|
23
|
-
const value = this.state.get(key);
|
|
24
|
-
if (value) {
|
|
25
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
26
|
-
this._hits++;
|
|
27
|
-
}
|
|
28
|
-
this.state.delete(key);
|
|
29
|
-
this.state.set(key, value);
|
|
30
|
-
return value;
|
|
31
|
-
}
|
|
32
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
33
|
-
this._misses++;
|
|
34
|
-
}
|
|
35
|
-
const newValue = this.doWork(key);
|
|
36
|
-
this.set(key, newValue);
|
|
37
|
-
return newValue;
|
|
38
|
-
}
|
|
39
|
-
set(key, value) {
|
|
40
|
-
if (this.state.size === this.size) {
|
|
41
|
-
for (const [k] of this.state) {
|
|
42
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
43
|
-
this._ejected++;
|
|
44
|
-
}
|
|
45
|
-
this.state.delete(k);
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
this.state.set(key, value);
|
|
50
|
-
}
|
|
51
|
-
clear() {
|
|
52
|
-
this.state.clear();
|
|
53
|
-
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
54
|
-
this._hits = 0;
|
|
55
|
-
this._misses = 0;
|
|
56
|
-
this._ejected = 0;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const STRING_DASHERIZE_REGEXP = /[ _]/g;
|
|
61
|
-
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
62
|
-
const STRING_DASHERIZE_CACHE = new LRUCache(key => key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-'));
|
|
63
|
-
|
|
64
|
-
// eslint-disable-next-line no-useless-escape
|
|
65
|
-
const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
|
|
66
|
-
const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
|
|
67
|
-
const CAMELIZE_CACHE = new LRUCache(key => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : '').replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase()));
|
|
68
|
-
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
|
|
69
|
-
// eslint-disable-next-line no-useless-escape
|
|
70
|
-
const STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
|
|
71
|
-
const UNDERSCORE_CACHE = new LRUCache(str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase());
|
|
72
|
-
const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
|
|
73
|
-
const CAPITALIZE_CACHE = new LRUCache(str => str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase()));
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
Replaces underscores, spaces, or camelCase with dashes.
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
import { dasherize } from '@ember-data/request-utils/string';
|
|
80
|
-
|
|
81
|
-
dasherize('innerHTML'); // 'inner-html'
|
|
82
|
-
dasherize('action_name'); // 'action-name'
|
|
83
|
-
dasherize('css-class-name'); // 'css-class-name'
|
|
84
|
-
dasherize('my favorite items'); // 'my-favorite-items'
|
|
85
|
-
dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
@typedoc
|
|
89
|
-
*/
|
|
90
|
-
function dasherize(str) {
|
|
91
|
-
return STRING_DASHERIZE_CACHE.get(str);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
Returns the lowerCamelCase form of a string.
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
import { camelize } from '@ember-data/request-utils/string';
|
|
99
|
-
|
|
100
|
-
camelize('innerHTML'); // 'innerHTML'
|
|
101
|
-
camelize('action_name'); // 'actionName'
|
|
102
|
-
camelize('css-class-name'); // 'cssClassName'
|
|
103
|
-
camelize('my favorite items'); // 'myFavoriteItems'
|
|
104
|
-
camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
105
|
-
camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
@typedoc
|
|
109
|
-
*/
|
|
110
|
-
function camelize(str) {
|
|
111
|
-
return CAMELIZE_CACHE.get(str);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
Returns the lower\_case\_and\_underscored form of a string.
|
|
116
|
-
|
|
117
|
-
```js
|
|
118
|
-
import { underscore } from '@ember-data/request-utils/string';
|
|
119
|
-
|
|
120
|
-
underscore('innerHTML'); // 'inner_html'
|
|
121
|
-
underscore('action_name'); // 'action_name'
|
|
122
|
-
underscore('css-class-name'); // 'css_class_name'
|
|
123
|
-
underscore('my favorite items'); // 'my_favorite_items'
|
|
124
|
-
underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
@typedoc
|
|
128
|
-
*/
|
|
129
|
-
function underscore(str) {
|
|
130
|
-
return UNDERSCORE_CACHE.get(str);
|
|
131
|
-
}
|
|
132
9
|
|
|
133
10
|
/**
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
```js
|
|
137
|
-
import { capitalize } from '@ember-data/request-utils/string';
|
|
11
|
+
* @module @ember-data/request-utils/string
|
|
12
|
+
*/
|
|
138
13
|
|
|
139
|
-
capitalize('innerHTML') // 'InnerHTML'
|
|
140
|
-
capitalize('action_name') // 'Action_name'
|
|
141
|
-
capitalize('css-class-name') // 'Css-class-name'
|
|
142
|
-
capitalize('my favorite items') // 'My favorite items'
|
|
143
|
-
capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
@typedoc
|
|
147
|
-
*/
|
|
148
|
-
function capitalize(str) {
|
|
149
|
-
return CAPITALIZE_CACHE.get(str);
|
|
150
|
-
}
|
|
151
|
-
function setMaxLRUCacheSize(size) {
|
|
152
|
-
CAMELIZE_CACHE.size = size;
|
|
153
|
-
UNDERSCORE_CACHE.size = size;
|
|
154
|
-
CAPITALIZE_CACHE.size = size;
|
|
155
|
-
STRING_DASHERIZE_CACHE.size = size;
|
|
156
|
-
}
|
|
157
14
|
const BLANK_REGEX = /^\s*$/;
|
|
158
15
|
const LAST_WORD_DASHED_REGEX = /([\w/-]+[_/\s-])([a-z\d]+$)/;
|
|
159
16
|
const LAST_WORD_CAMELIZED_REGEX = /([\w/\s-]+)([A-Z][a-z\d]*$)/;
|
|
@@ -169,14 +26,54 @@ const IRREGULAR = new Map();
|
|
|
169
26
|
const INVERSE_IRREGULAR = new Map();
|
|
170
27
|
const SINGULAR_RULES = new Map(defaultRules.singular.reverse());
|
|
171
28
|
const PLURAL_RULES = new Map(defaultRules.plurals.reverse());
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Marks a word as uncountable. Uncountable words are not pluralized
|
|
32
|
+
* or singularized.
|
|
33
|
+
*
|
|
34
|
+
* @method uncountable
|
|
35
|
+
* @public
|
|
36
|
+
* @static
|
|
37
|
+
* @for @ember-data/request-utils/string
|
|
38
|
+
* @param {String} word
|
|
39
|
+
* @return {void}
|
|
40
|
+
* @since 4.13.0
|
|
41
|
+
*/
|
|
172
42
|
function uncountable(word) {
|
|
173
43
|
UNCOUNTABLE.add(word.toLowerCase());
|
|
174
44
|
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Marks a list of words as uncountable. Uncountable words are not pluralized
|
|
48
|
+
* or singularized.
|
|
49
|
+
*
|
|
50
|
+
* @method loadUncountable
|
|
51
|
+
* @public
|
|
52
|
+
* @static
|
|
53
|
+
* @for @ember-data/request-utils/string
|
|
54
|
+
* @param {Array<String>} uncountables
|
|
55
|
+
* @return {void}
|
|
56
|
+
* @since 4.13.0
|
|
57
|
+
*/
|
|
175
58
|
function loadUncountable(uncountables) {
|
|
176
59
|
uncountables.forEach(word => {
|
|
177
60
|
uncountable(word);
|
|
178
61
|
});
|
|
179
62
|
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Marks a word as irregular. Irregular words have unique
|
|
66
|
+
* pluralization and singularization rules.
|
|
67
|
+
*
|
|
68
|
+
* @method irregular
|
|
69
|
+
* @public
|
|
70
|
+
* @static
|
|
71
|
+
* @for @ember-data/request-utils/string
|
|
72
|
+
* @param {String} single
|
|
73
|
+
* @param {String} plur
|
|
74
|
+
* @return {void}
|
|
75
|
+
* @since 4.13.0
|
|
76
|
+
*/
|
|
180
77
|
function irregular(single, plur) {
|
|
181
78
|
//pluralizing
|
|
182
79
|
IRREGULAR.set(single.toLowerCase(), plur);
|
|
@@ -186,6 +83,19 @@ function irregular(single, plur) {
|
|
|
186
83
|
INVERSE_IRREGULAR.set(plur.toLowerCase(), single);
|
|
187
84
|
INVERSE_IRREGULAR.set(single.toLowerCase(), single);
|
|
188
85
|
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Marks a list of word pairs as irregular. Irregular words have unique
|
|
89
|
+
* pluralization and singularization rules.
|
|
90
|
+
*
|
|
91
|
+
* @method loadIrregular
|
|
92
|
+
* @public
|
|
93
|
+
* @static
|
|
94
|
+
* @for @ember-data/request-utils/string
|
|
95
|
+
* @param {Array<Array<String>>} irregularPairs
|
|
96
|
+
* @return {void}
|
|
97
|
+
* @since 4.13.0
|
|
98
|
+
*/
|
|
189
99
|
function loadIrregular(irregularPairs) {
|
|
190
100
|
irregularPairs.forEach(pair => {
|
|
191
101
|
//pluralizing
|
|
@@ -198,10 +108,32 @@ function loadIrregular(irregularPairs) {
|
|
|
198
108
|
});
|
|
199
109
|
}
|
|
200
110
|
loadIrregular(defaultRules.irregularPairs);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Clears the caches for singularize and pluralize.
|
|
114
|
+
*
|
|
115
|
+
* @method clear
|
|
116
|
+
* @public
|
|
117
|
+
* @static
|
|
118
|
+
* @for @ember-data/request-utils/string
|
|
119
|
+
* @return {void}
|
|
120
|
+
* @since 4.13.0
|
|
121
|
+
*/
|
|
201
122
|
function clear() {
|
|
202
123
|
SINGULARS.clear();
|
|
203
124
|
PLURALS.clear();
|
|
204
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Resets the inflection rules to the defaults.
|
|
129
|
+
*
|
|
130
|
+
* @method resetToDefaults
|
|
131
|
+
* @public
|
|
132
|
+
* @static
|
|
133
|
+
* @for @ember-data/request-utils/string
|
|
134
|
+
* @return {void}
|
|
135
|
+
* @since 4.13.0
|
|
136
|
+
*/
|
|
205
137
|
function resetToDefaults() {
|
|
206
138
|
clearRules();
|
|
207
139
|
defaultRules.uncountable.forEach(v => UNCOUNTABLE.add(v));
|
|
@@ -209,6 +141,18 @@ function resetToDefaults() {
|
|
|
209
141
|
defaultRules.plurals.forEach(v => PLURAL_RULES.set(v[0], v[1]));
|
|
210
142
|
loadIrregular(defaultRules.irregularPairs);
|
|
211
143
|
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Clears all inflection rules
|
|
147
|
+
* and resets the caches for singularize and pluralize.
|
|
148
|
+
*
|
|
149
|
+
* @method clearRules
|
|
150
|
+
* @public
|
|
151
|
+
* @static
|
|
152
|
+
* @for @ember-data/request-utils/string
|
|
153
|
+
* @return {void}
|
|
154
|
+
* @since 4.13.0
|
|
155
|
+
*/
|
|
212
156
|
function clearRules() {
|
|
213
157
|
SINGULARS.clear();
|
|
214
158
|
PLURALS.clear();
|
|
@@ -218,6 +162,18 @@ function clearRules() {
|
|
|
218
162
|
SINGULAR_RULES.clear();
|
|
219
163
|
PLURAL_RULES.clear();
|
|
220
164
|
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Singularizes a word.
|
|
168
|
+
*
|
|
169
|
+
* @method singularize
|
|
170
|
+
* @public
|
|
171
|
+
* @static
|
|
172
|
+
* @for @ember-data/request-utils/string
|
|
173
|
+
* @param {String} word
|
|
174
|
+
* @return {String}
|
|
175
|
+
* @since 4.13.0
|
|
176
|
+
*/
|
|
221
177
|
function singularize(word) {
|
|
222
178
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
223
179
|
if (!test) {
|
|
@@ -227,6 +183,18 @@ function singularize(word) {
|
|
|
227
183
|
if (!word) return '';
|
|
228
184
|
return SINGULARS.get(word);
|
|
229
185
|
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Pluralizes a word.
|
|
189
|
+
*
|
|
190
|
+
* @method pluralize
|
|
191
|
+
* @public
|
|
192
|
+
* @static
|
|
193
|
+
* @for @ember-data/request-utils/string
|
|
194
|
+
* @param {String} word
|
|
195
|
+
* @return {String}
|
|
196
|
+
* @since 4.13.0
|
|
197
|
+
*/
|
|
230
198
|
function pluralize(word) {
|
|
231
199
|
macroCondition(getGlobalConfig().WarpDrive.env.DEBUG) ? (test => {
|
|
232
200
|
if (!test) {
|
|
@@ -244,6 +212,19 @@ function unshiftMap(v, map) {
|
|
|
244
212
|
map.set(rule[0], rule[1]);
|
|
245
213
|
});
|
|
246
214
|
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Adds a pluralization rule.
|
|
218
|
+
*
|
|
219
|
+
* @method plural
|
|
220
|
+
* @public
|
|
221
|
+
* @static
|
|
222
|
+
* @for @ember-data/request-utils/string
|
|
223
|
+
* @param {RegExp} regex
|
|
224
|
+
* @param {String} string
|
|
225
|
+
* @return {void}
|
|
226
|
+
* @since 4.13.0
|
|
227
|
+
*/
|
|
247
228
|
function plural(regex, string) {
|
|
248
229
|
// rule requires reordering if exists, so remove it first
|
|
249
230
|
if (PLURAL_RULES.has(regex)) {
|
|
@@ -253,6 +234,19 @@ function plural(regex, string) {
|
|
|
253
234
|
// reorder
|
|
254
235
|
unshiftMap([regex, string], PLURAL_RULES);
|
|
255
236
|
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Adds a singularization rule.
|
|
240
|
+
*
|
|
241
|
+
* @method singular
|
|
242
|
+
* @public
|
|
243
|
+
* @static
|
|
244
|
+
* @for @ember-data/request-utils/string
|
|
245
|
+
* @param {RegExp} regex
|
|
246
|
+
* @param {String} string
|
|
247
|
+
* @return {void}
|
|
248
|
+
* @since 4.13.0
|
|
249
|
+
*/
|
|
256
250
|
function singular(regex, string) {
|
|
257
251
|
// rule requires reordering if exists, so remove it first
|
|
258
252
|
if (SINGULAR_RULES.has(regex)) {
|
|
@@ -308,4 +302,4 @@ function inflect(word, typeRules, irregulars) {
|
|
|
308
302
|
}
|
|
309
303
|
return word;
|
|
310
304
|
}
|
|
311
|
-
export { singular as a, plural as b, loadUncountable as c, clear as d, clearRules as e,
|
|
305
|
+
export { singular as a, plural as b, loadUncountable as c, clear as d, clearRules as e, defaultRules as f, irregular as i, loadIrregular as l, pluralize as p, resetToDefaults as r, singularize as s, uncountable as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inflect-CwI_k2it.js","sources":["../src/-private/string/inflections.ts","../src/-private/string/inflect.ts"],"sourcesContent":["export type RulesArray = Array<[RegExp, string]>;\ntype DefaultRulesType = {\n plurals: RulesArray;\n singular: RulesArray;\n irregularPairs: Array<[string, string]>;\n uncountable: string[];\n};\n\nexport const defaultRules: DefaultRulesType = {\n plurals: [\n [/$/, 's'],\n [/s$/i, 's'],\n [/^(ax|test)is$/i, '$1es'],\n [/(octop|vir)us$/i, '$1i'],\n [/(octop|vir)i$/i, '$1i'],\n [/(alias|status|bonus)$/i, '$1es'],\n [/(bu)s$/i, '$1ses'],\n [/(buffal|tomat)o$/i, '$1oes'],\n [/([ti])um$/i, '$1a'],\n [/([ti])a$/i, '$1a'],\n [/sis$/i, 'ses'],\n [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'],\n [/(hive)$/i, '$1s'],\n [/([^aeiouy]|qu)y$/i, '$1ies'],\n [/(x|ch|ss|sh)$/i, '$1es'],\n [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'],\n [/^(m|l)ouse$/i, '$1ice'],\n [/^(m|l)ice$/i, '$1ice'],\n [/^(ox)$/i, '$1en'],\n [/^(oxen)$/i, '$1'],\n [/(quiz)$/i, '$1zes'],\n ],\n\n singular: [\n [/s$/i, ''],\n [/(ss)$/i, '$1'],\n [/(n)ews$/i, '$1ews'],\n [/([ti])a$/i, '$1um'],\n [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'],\n [/(^analy)(sis|ses)$/i, '$1sis'],\n [/([^f])ves$/i, '$1fe'],\n [/(hive)s$/i, '$1'],\n [/(tive)s$/i, '$1'],\n [/([lr])ves$/i, '$1f'],\n [/([^aeiouy]|qu)ies$/i, '$1y'],\n [/(s)eries$/i, '$1eries'],\n [/(m)ovies$/i, '$1ovie'],\n [/(x|ch|ss|sh)es$/i, '$1'],\n [/^(m|l)ice$/i, '$1ouse'],\n [/(bus)(es)?$/i, '$1'],\n [/(o)es$/i, '$1'],\n [/(shoe)s$/i, '$1'],\n [/(cris|test)(is|es)$/i, '$1is'],\n [/^(a)x[ie]s$/i, '$1xis'],\n [/(octop|vir)(us|i)$/i, '$1us'],\n [/(alias|status|bonus)(es)?$/i, '$1'],\n [/^(ox)en/i, '$1'],\n [/(vert|ind)ices$/i, '$1ex'],\n [/(matr)ices$/i, '$1ix'],\n [/(quiz)zes$/i, '$1'],\n [/(database)s$/i, '$1'],\n ],\n\n irregularPairs: [\n ['person', 'people'],\n ['man', 'men'],\n ['child', 'children'],\n ['sex', 'sexes'],\n ['move', 'moves'],\n ['cow', 'kine'],\n ['zombie', 'zombies'],\n ],\n\n uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police'],\n};\n","/**\n * @module @ember-data/request-utils/string\n */\nimport { assert } from '@warp-drive/build-config/macros';\n\nimport { defaultRules } from './inflections';\nimport { capitalize, LRUCache } from './transform';\n\nconst BLANK_REGEX = /^\\s*$/;\nconst LAST_WORD_DASHED_REGEX = /([\\w/-]+[_/\\s-])([a-z\\d]+$)/;\nconst LAST_WORD_CAMELIZED_REGEX = /([\\w/\\s-]+)([A-Z][a-z\\d]*$)/;\nconst CAMELIZED_REGEX = /[A-Z][a-z\\d]*$/;\n\nconst SINGULARS = new LRUCache<string, string>((word: string) => {\n return _singularize(word);\n});\nconst PLURALS = new LRUCache<string, string>((word: string) => {\n return _pluralize(word);\n});\nconst UNCOUNTABLE = new Set(defaultRules.uncountable);\nconst IRREGULAR: Map<string, string> = new Map();\nconst INVERSE_IRREGULAR: Map<string, string> = new Map();\nconst SINGULAR_RULES = new Map(defaultRules.singular.reverse());\nconst PLURAL_RULES = new Map(defaultRules.plurals.reverse());\n\n/**\n * Marks a word as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @method uncountable\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} word\n * @return {void}\n * @since 4.13.0\n */\nexport function uncountable(word: string) {\n UNCOUNTABLE.add(word.toLowerCase());\n}\n\n/**\n * Marks a list of words as uncountable. Uncountable words are not pluralized\n * or singularized.\n *\n * @method loadUncountable\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {Array<String>} uncountables\n * @return {void}\n * @since 4.13.0\n */\nexport function loadUncountable(uncountables: string[]) {\n uncountables.forEach((word) => {\n uncountable(word);\n });\n}\n\n/**\n * Marks a word as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @method irregular\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} single\n * @param {String} plur\n * @return {void}\n * @since 4.13.0\n */\nexport function irregular(single: string, plur: string) {\n //pluralizing\n IRREGULAR.set(single.toLowerCase(), plur);\n IRREGULAR.set(plur.toLowerCase(), plur);\n\n //singularizing\n INVERSE_IRREGULAR.set(plur.toLowerCase(), single);\n INVERSE_IRREGULAR.set(single.toLowerCase(), single);\n}\n\n/**\n * Marks a list of word pairs as irregular. Irregular words have unique\n * pluralization and singularization rules.\n *\n * @method loadIrregular\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {Array<Array<String>>} irregularPairs\n * @return {void}\n * @since 4.13.0\n */\nexport function loadIrregular(irregularPairs: Array<[string, string]>) {\n irregularPairs.forEach((pair) => {\n //pluralizing\n IRREGULAR.set(pair[0].toLowerCase(), pair[1]);\n IRREGULAR.set(pair[1].toLowerCase(), pair[1]);\n\n //singularizing\n INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);\n INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);\n });\n}\nloadIrregular(defaultRules.irregularPairs);\n\n/**\n * Clears the caches for singularize and pluralize.\n *\n * @method clear\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @return {void}\n * @since 4.13.0\n */\nexport function clear() {\n SINGULARS.clear();\n PLURALS.clear();\n}\n\n/**\n * Resets the inflection rules to the defaults.\n *\n * @method resetToDefaults\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @return {void}\n * @since 4.13.0\n */\nexport function resetToDefaults() {\n clearRules();\n defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));\n defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));\n defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));\n loadIrregular(defaultRules.irregularPairs);\n}\n\n/**\n * Clears all inflection rules\n * and resets the caches for singularize and pluralize.\n *\n * @method clearRules\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @return {void}\n * @since 4.13.0\n */\nexport function clearRules() {\n SINGULARS.clear();\n PLURALS.clear();\n UNCOUNTABLE.clear();\n IRREGULAR.clear();\n INVERSE_IRREGULAR.clear();\n SINGULAR_RULES.clear();\n PLURAL_RULES.clear();\n}\n\n/**\n * Singularizes a word.\n *\n * @method singularize\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function singularize(word: string) {\n assert(`singularize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return SINGULARS.get(word);\n}\n\n/**\n * Pluralizes a word.\n *\n * @method pluralize\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} word\n * @return {String}\n * @since 4.13.0\n */\nexport function pluralize(word: string) {\n assert(`pluralize expects to receive a non-empty string`, typeof word === 'string' && word.length > 0);\n if (!word) return '';\n return PLURALS.get(word);\n}\n\nfunction unshiftMap<K, V>(v: [K, V], map: Map<K, V>) {\n // reorder\n const rules = [v, ...map.entries()];\n map.clear();\n rules.forEach((rule) => {\n map.set(rule[0], rule[1]);\n });\n}\n\n/**\n * Adds a pluralization rule.\n *\n * @method plural\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function plural(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (PLURAL_RULES.has(regex)) {\n PLURAL_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], PLURAL_RULES);\n}\n\n/**\n * Adds a singularization rule.\n *\n * @method singular\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {RegExp} regex\n * @param {String} string\n * @return {void}\n * @since 4.13.0\n */\nexport function singular(regex: RegExp, string: string) {\n // rule requires reordering if exists, so remove it first\n if (SINGULAR_RULES.has(regex)) {\n SINGULAR_RULES.delete(regex);\n }\n\n // reorder\n unshiftMap([regex, string], SINGULAR_RULES);\n}\n\nfunction _pluralize(word: string) {\n return inflect(word, PLURAL_RULES, IRREGULAR);\n}\n\nfunction _singularize(word: string) {\n return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);\n}\n\nfunction inflect(word: string, typeRules: Map<RegExp, string>, irregulars: Map<string, string>) {\n // empty strings\n const isBlank = !word || BLANK_REGEX.test(word);\n if (isBlank) {\n return word;\n }\n\n // basic uncountables\n const lowercase = word.toLowerCase();\n if (UNCOUNTABLE.has(lowercase)) {\n return word;\n }\n\n // adv uncountables\n const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);\n const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;\n if (lastWord && UNCOUNTABLE.has(lastWord)) {\n return word;\n }\n\n // handle irregulars\n const isCamelized = CAMELIZED_REGEX.test(word);\n for (let [rule, substitution] of irregulars) {\n if (lowercase.match(rule + '$')) {\n if (isCamelized && lastWord && irregulars.has(lastWord)) {\n substitution = capitalize(substitution);\n rule = capitalize(rule);\n }\n\n return word.replace(new RegExp(rule, 'i'), substitution);\n }\n }\n\n // do the actual inflection\n for (const [rule, substitution] of typeRules) {\n if (rule.test(word)) {\n return word.replace(rule, substitution);\n }\n }\n\n return word;\n}\n"],"names":["defaultRules","plurals","singular","irregularPairs","uncountable","BLANK_REGEX","LAST_WORD_DASHED_REGEX","LAST_WORD_CAMELIZED_REGEX","CAMELIZED_REGEX","SINGULARS","LRUCache","word","_singularize","PLURALS","_pluralize","UNCOUNTABLE","Set","IRREGULAR","Map","INVERSE_IRREGULAR","SINGULAR_RULES","reverse","PLURAL_RULES","add","toLowerCase","loadUncountable","uncountables","forEach","irregular","single","plur","set","loadIrregular","pair","clear","resetToDefaults","clearRules","v","singularize","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","test","Error","length","get","pluralize","unshiftMap","map","rules","entries","rule","plural","regex","string","has","delete","inflect","typeRules","irregulars","isBlank","lowercase","wordSplit","exec","lastWord","isCamelized","substitution","match","capitalize","replace","RegExp"],"mappings":";;;AAQO,MAAMA,YAA8B,GAAG;AAC5CC,EAAAA,OAAO,EAAE,CACP,CAAC,GAAG,EAAE,GAAG,CAAC,EACV,CAAC,KAAK,EAAE,GAAG,CAAC,EACZ,CAAC,gBAAgB,EAAE,MAAM,CAAC,EAC1B,CAAC,iBAAiB,EAAE,KAAK,CAAC,EAC1B,CAAC,gBAAgB,EAAE,KAAK,CAAC,EACzB,CAAC,wBAAwB,EAAE,MAAM,CAAC,EAClC,CAAC,SAAS,EAAE,OAAO,CAAC,EACpB,CAAC,mBAAmB,EAAE,OAAO,CAAC,EAC9B,CAAC,YAAY,EAAE,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,CAAC;AACzB;AAEA,MAAA,OAAO1C,IAAI,CAAC4D,OAAO,CAAC,IAAIC,MAAM,CAACnB,IAAI,EAAE,GAAG,CAAC,EAAEe,YAAY,CAAC;AAC1D;AACF;;AAEA;EACA,KAAK,MAAM,CAACf,IAAI,EAAEe,YAAY,CAAC,IAAIR,SAAS,EAAE;AAC5C,IAAA,IAAIP,IAAI,CAACT,IAAI,CAACjC,IAAI,CAAC,EAAE;AACnB,MAAA,OAAOA,IAAI,CAAC4D,OAAO,CAAClB,IAAI,EAAEe,YAAY,CAAC;AACzC;AACF;AAEA,EAAA,OAAOzD,IAAI;AACb;;;;"}
|
package/dist/string.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { d as clear, e as clearRules, i as irregular, l as loadIrregular, c as loadUncountable, b as plural, p as pluralize, r as resetToDefaults, a as singular, s as singularize, u as uncountable } from "./inflect-CwI_k2it.js";
|
|
2
|
+
export { c as camelize, a as capitalize, d as dasherize, s as setMaxLRUCacheSize, u as underscore } from "./transform-1PDozfHr.js";
|
package/dist/string.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"string.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { macroCondition, getGlobalConfig } from '@embroider/macros';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @module @ember-data/request-utils/string
|
|
5
|
+
*/
|
|
6
|
+
const DEFAULT_MAX_CACHE_SIZE = 10_000;
|
|
7
|
+
class LRUCache {
|
|
8
|
+
// debug stats
|
|
9
|
+
|
|
10
|
+
constructor(doWork, size) {
|
|
11
|
+
this.size = size || DEFAULT_MAX_CACHE_SIZE;
|
|
12
|
+
this.state = new Map();
|
|
13
|
+
this.doWork = doWork;
|
|
14
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
15
|
+
this._hits = 0;
|
|
16
|
+
this._misses = 0;
|
|
17
|
+
this._ejected = 0;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
get(key) {
|
|
21
|
+
const value = this.state.get(key);
|
|
22
|
+
if (value) {
|
|
23
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
24
|
+
this._hits++;
|
|
25
|
+
}
|
|
26
|
+
this.state.delete(key);
|
|
27
|
+
this.state.set(key, value);
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
31
|
+
this._misses++;
|
|
32
|
+
}
|
|
33
|
+
const newValue = this.doWork(key);
|
|
34
|
+
this.set(key, newValue);
|
|
35
|
+
return newValue;
|
|
36
|
+
}
|
|
37
|
+
set(key, value) {
|
|
38
|
+
if (this.state.size === this.size) {
|
|
39
|
+
for (const [k] of this.state) {
|
|
40
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
41
|
+
this._ejected++;
|
|
42
|
+
}
|
|
43
|
+
this.state.delete(k);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this.state.set(key, value);
|
|
48
|
+
}
|
|
49
|
+
clear() {
|
|
50
|
+
this.state.clear();
|
|
51
|
+
if (macroCondition(getGlobalConfig().WarpDrive.env.DEBUG)) {
|
|
52
|
+
this._hits = 0;
|
|
53
|
+
this._misses = 0;
|
|
54
|
+
this._ejected = 0;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const STRING_DASHERIZE_REGEXP = /[ _]/g;
|
|
59
|
+
const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
|
|
60
|
+
const STRING_DASHERIZE_CACHE = new LRUCache(key => key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-'));
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line no-useless-escape
|
|
63
|
+
const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
|
|
64
|
+
const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
|
|
65
|
+
const CAMELIZE_CACHE = new LRUCache(key => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : '').replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase()));
|
|
66
|
+
const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
|
|
67
|
+
// eslint-disable-next-line no-useless-escape
|
|
68
|
+
const STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
|
|
69
|
+
const UNDERSCORE_CACHE = new LRUCache(str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase());
|
|
70
|
+
const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
|
|
71
|
+
const CAPITALIZE_CACHE = new LRUCache(str => str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase()));
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Replaces underscores, spaces, or camelCase with dashes.
|
|
75
|
+
*
|
|
76
|
+
* ```js
|
|
77
|
+
* import { dasherize } from '@ember-data/request-utils/string';
|
|
78
|
+
*
|
|
79
|
+
* dasherize('innerHTML'); // 'inner-html'
|
|
80
|
+
* dasherize('action_name'); // 'action-name'
|
|
81
|
+
* dasherize('css-class-name'); // 'css-class-name'
|
|
82
|
+
* dasherize('my favorite items'); // 'my-favorite-items'
|
|
83
|
+
* dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @method dasherize
|
|
87
|
+
* @public
|
|
88
|
+
* @static
|
|
89
|
+
* @for @ember-data/request-utils/string
|
|
90
|
+
* @param {String} str
|
|
91
|
+
* @return {String}
|
|
92
|
+
* @since 4.13.0
|
|
93
|
+
*/
|
|
94
|
+
function dasherize(str) {
|
|
95
|
+
return STRING_DASHERIZE_CACHE.get(str);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns the lowerCamelCase form of a string.
|
|
100
|
+
*
|
|
101
|
+
* ```js
|
|
102
|
+
* import { camelize } from '@ember-data/request-utils/string';
|
|
103
|
+
*
|
|
104
|
+
* camelize('innerHTML'); // 'innerHTML'
|
|
105
|
+
* camelize('action_name'); // 'actionName'
|
|
106
|
+
* camelize('css-class-name'); // 'cssClassName'
|
|
107
|
+
* camelize('my favorite items'); // 'myFavoriteItems'
|
|
108
|
+
* camelize('My Favorite Items'); // 'myFavoriteItems'
|
|
109
|
+
* camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @method camelize
|
|
113
|
+
* @public
|
|
114
|
+
* @static
|
|
115
|
+
* @for @ember-data/request-utils/string
|
|
116
|
+
* @param {String} str
|
|
117
|
+
* @return {String}
|
|
118
|
+
* @since 4.13.0
|
|
119
|
+
*/
|
|
120
|
+
function camelize(str) {
|
|
121
|
+
return CAMELIZE_CACHE.get(str);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns the lower\_case\_and\_underscored form of a string.
|
|
126
|
+
*
|
|
127
|
+
* ```js
|
|
128
|
+
* import { underscore } from '@ember-data/request-utils/string';
|
|
129
|
+
*
|
|
130
|
+
* underscore('innerHTML'); // 'inner_html'
|
|
131
|
+
* underscore('action_name'); // 'action_name'
|
|
132
|
+
* underscore('css-class-name'); // 'css_class_name'
|
|
133
|
+
* underscore('my favorite items'); // 'my_favorite_items'
|
|
134
|
+
* underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* @method underscore
|
|
138
|
+
* @public
|
|
139
|
+
* @static
|
|
140
|
+
* @for @ember-data/request-utils/string
|
|
141
|
+
* @param {String} str
|
|
142
|
+
* @return {String}
|
|
143
|
+
* @since 4.13.0
|
|
144
|
+
*/
|
|
145
|
+
function underscore(str) {
|
|
146
|
+
return UNDERSCORE_CACHE.get(str);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Returns the Capitalized form of a string
|
|
151
|
+
*
|
|
152
|
+
* ```js
|
|
153
|
+
* import { capitalize } from '@ember-data/request-utils/string';
|
|
154
|
+
*
|
|
155
|
+
* capitalize('innerHTML') // 'InnerHTML'
|
|
156
|
+
* capitalize('action_name') // 'Action_name'
|
|
157
|
+
* capitalize('css-class-name') // 'Css-class-name'
|
|
158
|
+
* capitalize('my favorite items') // 'My favorite items'
|
|
159
|
+
* capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
|
|
160
|
+
* ```
|
|
161
|
+
*
|
|
162
|
+
* @method capitalize
|
|
163
|
+
* @static
|
|
164
|
+
* @public
|
|
165
|
+
* @for @ember-data/request-utils/string
|
|
166
|
+
* @param {String} str
|
|
167
|
+
* @return {String}
|
|
168
|
+
* @since 4.13.0
|
|
169
|
+
*/
|
|
170
|
+
function capitalize(str) {
|
|
171
|
+
return CAPITALIZE_CACHE.get(str);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Sets the maximum size of the LRUCache for all string transformation functions.
|
|
176
|
+
* The default size is 10,000.
|
|
177
|
+
*
|
|
178
|
+
* @method setMaxLRUCacheSize
|
|
179
|
+
* @public
|
|
180
|
+
* @static
|
|
181
|
+
* @for @ember-data/request-utils/string
|
|
182
|
+
* @param {Number} size
|
|
183
|
+
* @return {void}
|
|
184
|
+
* @since 4.13.0
|
|
185
|
+
*/
|
|
186
|
+
function setMaxLRUCacheSize(size) {
|
|
187
|
+
CAMELIZE_CACHE.size = size;
|
|
188
|
+
UNDERSCORE_CACHE.size = size;
|
|
189
|
+
CAPITALIZE_CACHE.size = size;
|
|
190
|
+
STRING_DASHERIZE_CACHE.size = size;
|
|
191
|
+
}
|
|
192
|
+
export { LRUCache as L, capitalize as a, camelize as c, dasherize as d, setMaxLRUCacheSize as s, underscore as u };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-1PDozfHr.js","sources":["../src/-private/string/transform.ts"],"sourcesContent":["/**\n * @module @ember-data/request-utils/string\n */\nimport { DEBUG } from '@warp-drive/build-config/env';\n\nconst DEFAULT_MAX_CACHE_SIZE = 10_000;\nexport class LRUCache<T, V> {\n declare size: number;\n declare state: Map<T, V>;\n declare doWork: (k: T) => V;\n\n // debug stats\n declare _hits: number;\n declare _misses: number;\n declare _ejected: number;\n\n constructor(doWork: (k: T) => V, size?: number) {\n this.size = size || DEFAULT_MAX_CACHE_SIZE;\n this.state = new Map();\n this.doWork = doWork;\n\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n get(key: T) {\n const value = this.state.get(key);\n if (value) {\n if (DEBUG) {\n this._hits++;\n }\n this.state.delete(key);\n this.state.set(key, value);\n return value;\n }\n if (DEBUG) {\n this._misses++;\n }\n\n const newValue = this.doWork(key);\n this.set(key, newValue);\n return newValue;\n }\n\n set(key: T, value: V) {\n if (this.state.size === this.size) {\n for (const [k] of this.state) {\n if (DEBUG) {\n this._ejected++;\n }\n this.state.delete(k);\n break;\n }\n }\n this.state.set(key, value);\n }\n\n clear() {\n this.state.clear();\n if (DEBUG) {\n this._hits = 0;\n this._misses = 0;\n this._ejected = 0;\n }\n }\n}\n\nconst STRING_DASHERIZE_REGEXP = /[ _]/g;\nconst STRING_DECAMELIZE_REGEXP = /([a-z\\d])([A-Z])/g;\nconst STRING_DASHERIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-')\n);\n\n// eslint-disable-next-line no-useless-escape\nconst STRING_CAMELIZE_REGEXP_1 = /(\\-|\\_|\\.|\\s)+(.)?/g;\nconst STRING_CAMELIZE_REGEXP_2 = /(^|\\/)([A-Z])/g;\nconst CAMELIZE_CACHE = new LRUCache<string, string>((key: string) =>\n key\n .replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr: string | null) => (chr ? chr.toUpperCase() : ''))\n .replace(STRING_CAMELIZE_REGEXP_2, (match /*, separator, chr */) => match.toLowerCase())\n);\n\nconst STRING_UNDERSCORE_REGEXP_1 = /([a-z\\d])([A-Z]+)/g;\n// eslint-disable-next-line no-useless-escape\nconst STRING_UNDERSCORE_REGEXP_2 = /\\-|\\s+/g;\nconst UNDERSCORE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()\n);\n\nconst STRING_CAPITALIZE_REGEXP = /(^|\\/)([a-z\\u00C0-\\u024F])/g;\nconst CAPITALIZE_CACHE = new LRUCache<string, string>((str: string) =>\n str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase())\n);\n\n/**\n * Replaces underscores, spaces, or camelCase with dashes.\n *\n * ```js\n * import { dasherize } from '@ember-data/request-utils/string';\n *\n * dasherize('innerHTML'); // 'inner-html'\n * dasherize('action_name'); // 'action-name'\n * dasherize('css-class-name'); // 'css-class-name'\n * dasherize('my favorite items'); // 'my-favorite-items'\n * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'\n * ```\n *\n * @method dasherize\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function dasherize(str: string): string {\n return STRING_DASHERIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lowerCamelCase form of a string.\n *\n * ```js\n * import { camelize } from '@ember-data/request-utils/string';\n *\n * camelize('innerHTML'); // 'innerHTML'\n * camelize('action_name'); // 'actionName'\n * camelize('css-class-name'); // 'cssClassName'\n * camelize('my favorite items'); // 'myFavoriteItems'\n * camelize('My Favorite Items'); // 'myFavoriteItems'\n * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'\n * ```\n *\n * @method camelize\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function camelize(str: string): string {\n return CAMELIZE_CACHE.get(str);\n}\n\n/**\n * Returns the lower\\_case\\_and\\_underscored form of a string.\n *\n * ```js\n * import { underscore } from '@ember-data/request-utils/string';\n *\n * underscore('innerHTML'); // 'inner_html'\n * underscore('action_name'); // 'action_name'\n * underscore('css-class-name'); // 'css_class_name'\n * underscore('my favorite items'); // 'my_favorite_items'\n * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'\n * ```\n *\n * @method underscore\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function underscore(str: string): string {\n return UNDERSCORE_CACHE.get(str);\n}\n\n/**\n * Returns the Capitalized form of a string\n *\n * ```js\n * import { capitalize } from '@ember-data/request-utils/string';\n *\n * capitalize('innerHTML') // 'InnerHTML'\n * capitalize('action_name') // 'Action_name'\n * capitalize('css-class-name') // 'Css-class-name'\n * capitalize('my favorite items') // 'My favorite items'\n * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'\n * ```\n *\n * @method capitalize\n * @static\n * @public\n * @for @ember-data/request-utils/string\n * @param {String} str\n * @return {String}\n * @since 4.13.0\n */\nexport function capitalize(str: string): string {\n return CAPITALIZE_CACHE.get(str);\n}\n\n/**\n * Sets the maximum size of the LRUCache for all string transformation functions.\n * The default size is 10,000.\n *\n * @method setMaxLRUCacheSize\n * @public\n * @static\n * @for @ember-data/request-utils/string\n * @param {Number} size\n * @return {void}\n * @since 4.13.0\n */\nexport function setMaxLRUCacheSize(size: number) {\n CAMELIZE_CACHE.size = size;\n UNDERSCORE_CACHE.size = size;\n CAPITALIZE_CACHE.size = size;\n STRING_DASHERIZE_CACHE.size = size;\n}\n"],"names":["DEFAULT_MAX_CACHE_SIZE","LRUCache","constructor","doWork","size","state","Map","macroCondition","getGlobalConfig","WarpDrive","env","DEBUG","_hits","_misses","_ejected","get","key","value","delete","set","newValue","k","clear","STRING_DASHERIZE_REGEXP","STRING_DECAMELIZE_REGEXP","STRING_DASHERIZE_CACHE","replace","toLowerCase","STRING_CAMELIZE_REGEXP_1","STRING_CAMELIZE_REGEXP_2","CAMELIZE_CACHE","_match","_separator","chr","toUpperCase","match","STRING_UNDERSCORE_REGEXP_1","STRING_UNDERSCORE_REGEXP_2","UNDERSCORE_CACHE","str","STRING_CAPITALIZE_REGEXP","CAPITALIZE_CACHE","dasherize","camelize","underscore","capitalize","setMaxLRUCacheSize"],"mappings":";;AAAA;AACA;AACA;AAGA,MAAMA,sBAAsB,GAAG,MAAM;AAC9B,MAAMC,QAAQ,CAAO;AAK1B;;AAKAC,EAAAA,WAAWA,CAACC,MAAmB,EAAEC,IAAa,EAAE;AAC9C,IAAA,IAAI,CAACA,IAAI,GAAGA,IAAI,IAAIJ,sBAAsB;AAC1C,IAAA,IAAI,CAACK,KAAK,GAAG,IAAIC,GAAG,EAAE;IACtB,IAAI,CAACH,MAAM,GAAGA,MAAM;IAEpB,IAAAI,cAAA,CAAAC,eAAA,EAAA,CAAAC,SAAA,CAAAC,GAAA,CAAAC,KAAA,CAAW,EAAA;MACT,IAAI,CAACC,KAAK,GAAG,CAAC;MACd,IAAI,CAACC,OAAO,GAAG,CAAC;MAChB,IAAI,CAACC,QAAQ,GAAG,CAAC;AACnB;AACF;EACAC,GAAGA,CAACC,GAAM,EAAE;IACV,MAAMC,KAAK,GAAG,IAAI,CAACZ,KAAK,CAACU,GAAG,CAACC,GAAG,CAAC;AACjC,IAAA,IAAIC,KAAK,EAAE;MACT,IAAA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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,SAASA,CAACH,GAAW,EAAU;AAC7C,EAAA,OAAOd,sBAAsB,CAACV,GAAG,CAACwB,GAAG,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,QAAQA,CAACJ,GAAW,EAAU;AAC5C,EAAA,OAAOT,cAAc,CAACf,GAAG,CAACwB,GAAG,CAAC;AAChC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,UAAUA,CAACL,GAAW,EAAU;AAC9C,EAAA,OAAOD,gBAAgB,CAACvB,GAAG,CAACwB,GAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,UAAUA,CAACN,GAAW,EAAU;AAC9C,EAAA,OAAOE,gBAAgB,CAAC1B,GAAG,CAACwB,GAAG,CAAC;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,kBAAkBA,CAAC1C,IAAY,EAAE;EAC/C0B,cAAc,CAAC1B,IAAI,GAAGA,IAAI;EAC1BkC,gBAAgB,CAAClC,IAAI,GAAGA,IAAI;EAC5BqC,gBAAgB,CAACrC,IAAI,GAAGA,IAAI;EAC5BqB,sBAAsB,CAACrB,IAAI,GAAGA,IAAI;AACpC;;;;"}
|