@warp-drive-mirror/utilities 5.9.0-alpha.9 → 5.9.0-beta.1

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.
Files changed (149) hide show
  1. package/cjs-dist/string.cjs +349 -331
  2. package/cjs-dist/string.cjs.map +1 -0
  3. package/declarations/-private.d.ts +12 -1
  4. package/declarations/-private.d.ts.map +1 -0
  5. package/declarations/active-record.d.ts +260 -3
  6. package/declarations/active-record.d.ts.map +1 -0
  7. package/declarations/derivations.d.ts +26 -23
  8. package/declarations/derivations.d.ts.map +1 -0
  9. package/declarations/handlers.d.ts +282 -9
  10. package/declarations/handlers.d.ts.map +1 -0
  11. package/declarations/index-BeMAuqgZ.d.ts +462 -0
  12. package/declarations/index-BeMAuqgZ.d.ts.map +1 -0
  13. package/declarations/index.d.ts +2 -208
  14. package/declarations/json-api.d.ts +496 -5
  15. package/declarations/json-api.d.ts.map +1 -0
  16. package/declarations/rest.d.ts +258 -3
  17. package/declarations/rest.d.ts.map +1 -0
  18. package/declarations/string.d.ts +164 -13
  19. package/declarations/string.d.ts.map +1 -0
  20. package/dist/-private.js +2 -6
  21. package/dist/active-record.js +254 -379
  22. package/dist/active-record.js.map +1 -0
  23. package/dist/builder-utils-BkXwUT0x.js +16 -0
  24. package/dist/builder-utils-BkXwUT0x.js.map +1 -0
  25. package/dist/derivations.js +26 -26
  26. package/dist/derivations.js.map +1 -0
  27. package/dist/handlers.js +240 -283
  28. package/dist/handlers.js.map +1 -0
  29. package/dist/index.js +357 -335
  30. package/dist/index.js.map +1 -0
  31. package/dist/inflections-DzBsjJqj.js +80 -0
  32. package/dist/inflections-DzBsjJqj.js.map +1 -0
  33. package/dist/json-api.js +470 -706
  34. package/dist/json-api.js.map +1 -0
  35. package/dist/rest.js +254 -377
  36. package/dist/rest.js.map +1 -0
  37. package/dist/string-CWmAluxh.js +290 -0
  38. package/dist/string-CWmAluxh.js.map +1 -0
  39. package/dist/string.js +3 -1
  40. package/dist/unpkg/dev/-private.js +2 -6
  41. package/dist/unpkg/dev/active-record.js +253 -378
  42. package/dist/unpkg/dev/active-record.js.map +1 -0
  43. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js +16 -0
  44. package/dist/unpkg/dev/builder-utils-BkXwUT0x.js.map +1 -0
  45. package/dist/unpkg/dev/derivations.js +26 -26
  46. package/dist/unpkg/dev/derivations.js.map +1 -0
  47. package/dist/unpkg/dev/handlers.js +238 -282
  48. package/dist/unpkg/dev/handlers.js.map +1 -0
  49. package/dist/unpkg/dev/index.js +356 -336
  50. package/dist/unpkg/dev/index.js.map +1 -0
  51. package/dist/unpkg/dev/inflections-DzBsjJqj.js +80 -0
  52. package/dist/unpkg/dev/inflections-DzBsjJqj.js.map +1 -0
  53. package/dist/unpkg/dev/json-api.js +469 -706
  54. package/dist/unpkg/dev/json-api.js.map +1 -0
  55. package/dist/unpkg/dev/rest.js +253 -376
  56. package/dist/unpkg/dev/rest.js.map +1 -0
  57. package/dist/unpkg/dev/string-j4ur-TDs.js +289 -0
  58. package/dist/unpkg/dev/string-j4ur-TDs.js.map +1 -0
  59. package/dist/unpkg/dev/string.js +3 -1
  60. package/dist/unpkg/dev-deprecated/-private.js +2 -6
  61. package/dist/unpkg/dev-deprecated/active-record.js +253 -378
  62. package/dist/unpkg/dev-deprecated/active-record.js.map +1 -0
  63. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js +16 -0
  64. package/dist/unpkg/dev-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  65. package/dist/unpkg/dev-deprecated/derivations.js +26 -26
  66. package/dist/unpkg/dev-deprecated/derivations.js.map +1 -0
  67. package/dist/unpkg/dev-deprecated/handlers.js +238 -282
  68. package/dist/unpkg/dev-deprecated/handlers.js.map +1 -0
  69. package/dist/unpkg/dev-deprecated/index.js +356 -336
  70. package/dist/unpkg/dev-deprecated/index.js.map +1 -0
  71. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js +80 -0
  72. package/dist/unpkg/dev-deprecated/inflections-DzBsjJqj.js.map +1 -0
  73. package/dist/unpkg/dev-deprecated/json-api.js +469 -706
  74. package/dist/unpkg/dev-deprecated/json-api.js.map +1 -0
  75. package/dist/unpkg/dev-deprecated/rest.js +253 -376
  76. package/dist/unpkg/dev-deprecated/rest.js.map +1 -0
  77. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js +289 -0
  78. package/dist/unpkg/dev-deprecated/string-j4ur-TDs.js.map +1 -0
  79. package/dist/unpkg/dev-deprecated/string.js +3 -1
  80. package/dist/unpkg/prod/-private.js +2 -6
  81. package/dist/unpkg/prod/active-record.js +236 -351
  82. package/dist/unpkg/prod/active-record.js.map +1 -0
  83. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js +16 -0
  84. package/dist/unpkg/prod/builder-utils-BkXwUT0x.js.map +1 -0
  85. package/dist/unpkg/prod/derivations.js +26 -26
  86. package/dist/unpkg/prod/derivations.js.map +1 -0
  87. package/dist/unpkg/prod/handlers.js +231 -272
  88. package/dist/unpkg/prod/handlers.js.map +1 -0
  89. package/dist/unpkg/prod/index.js +265 -215
  90. package/dist/unpkg/prod/index.js.map +1 -0
  91. package/dist/unpkg/prod/inflections-DzBsjJqj.js +80 -0
  92. package/dist/unpkg/prod/inflections-DzBsjJqj.js.map +1 -0
  93. package/dist/unpkg/prod/json-api.js +446 -669
  94. package/dist/unpkg/prod/json-api.js.map +1 -0
  95. package/dist/unpkg/prod/rest.js +236 -349
  96. package/dist/unpkg/prod/rest.js.map +1 -0
  97. package/dist/unpkg/prod/string-T1ahjLdj.js +283 -0
  98. package/dist/unpkg/prod/string-T1ahjLdj.js.map +1 -0
  99. package/dist/unpkg/prod/string.js +3 -1
  100. package/dist/unpkg/prod-deprecated/-private.js +2 -6
  101. package/dist/unpkg/prod-deprecated/active-record.js +236 -351
  102. package/dist/unpkg/prod-deprecated/active-record.js.map +1 -0
  103. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js +16 -0
  104. package/dist/unpkg/prod-deprecated/builder-utils-BkXwUT0x.js.map +1 -0
  105. package/dist/unpkg/prod-deprecated/derivations.js +26 -26
  106. package/dist/unpkg/prod-deprecated/derivations.js.map +1 -0
  107. package/dist/unpkg/prod-deprecated/handlers.js +231 -272
  108. package/dist/unpkg/prod-deprecated/handlers.js.map +1 -0
  109. package/dist/unpkg/prod-deprecated/index.js +265 -215
  110. package/dist/unpkg/prod-deprecated/index.js.map +1 -0
  111. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js +80 -0
  112. package/dist/unpkg/prod-deprecated/inflections-DzBsjJqj.js.map +1 -0
  113. package/dist/unpkg/prod-deprecated/json-api.js +446 -669
  114. package/dist/unpkg/prod-deprecated/json-api.js.map +1 -0
  115. package/dist/unpkg/prod-deprecated/rest.js +236 -349
  116. package/dist/unpkg/prod-deprecated/rest.js.map +1 -0
  117. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js +283 -0
  118. package/dist/unpkg/prod-deprecated/string-T1ahjLdj.js.map +1 -0
  119. package/dist/unpkg/prod-deprecated/string.js +3 -1
  120. package/package.json +9 -9
  121. package/declarations/-private/active-record/find-record.d.ts +0 -64
  122. package/declarations/-private/active-record/query.d.ts +0 -53
  123. package/declarations/-private/active-record/save-record.d.ts +0 -146
  124. package/declarations/-private/builder-utils.d.ts +0 -4
  125. package/declarations/-private/handlers/auto-compress.d.ts +0 -158
  126. package/declarations/-private/handlers/gated.d.ts +0 -19
  127. package/declarations/-private/handlers/meta-doc.d.ts +0 -47
  128. package/declarations/-private/handlers/utils.d.ts +0 -41
  129. package/declarations/-private/json-api/-utils.d.ts +0 -109
  130. package/declarations/-private/json-api/find-record.d.ts +0 -84
  131. package/declarations/-private/json-api/query.d.ts +0 -100
  132. package/declarations/-private/json-api/save-record.d.ts +0 -228
  133. package/declarations/-private/json-api/serialize.d.ts +0 -70
  134. package/declarations/-private/rest/find-record.d.ts +0 -62
  135. package/declarations/-private/rest/query.d.ts +0 -53
  136. package/declarations/-private/rest/save-record.d.ts +0 -146
  137. package/declarations/-private/string/inflect.d.ts +0 -82
  138. package/declarations/-private/string/inflections.d.ts +0 -9
  139. package/declarations/-private/string/transform.d.ts +0 -77
  140. package/dist/builder-utils-Donkk-BZ.js +0 -22
  141. package/dist/inflect-BSG696t-.js +0 -344
  142. package/dist/unpkg/dev/builder-utils-Donkk-BZ.js +0 -22
  143. package/dist/unpkg/dev/inflect-BEv8WqY1.js +0 -343
  144. package/dist/unpkg/dev-deprecated/builder-utils-Donkk-BZ.js +0 -22
  145. package/dist/unpkg/dev-deprecated/inflect-BEv8WqY1.js +0 -343
  146. package/dist/unpkg/prod/builder-utils-Donkk-BZ.js +0 -22
  147. package/dist/unpkg/prod/inflect-Dh9dyEYx.js +0 -333
  148. package/dist/unpkg/prod-deprecated/builder-utils-Donkk-BZ.js +0 -22
  149. package/dist/unpkg/prod-deprecated/inflect-Dh9dyEYx.js +0 -333
@@ -1,417 +1,434 @@
1
- 'use strict';
2
-
3
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- const DEFAULT_MAX_CACHE_SIZE = 10_000;
6
-
2
+ //#region ../../node_modules/.pnpm/@warp-d_f6d5a2b6297864aac1090915a29560e9/node_modules/@warp-drive-mirror/core/dist/utils/string.js
3
+ const DEFAULT_MAX_CACHE_SIZE = 1e4;
7
4
  /**
8
- * An LRUCache implementation with upsert semantics.
9
- *
10
- * This implementation is *not* generic, but focuses on
11
- * performance tuning for the string transformation cases
12
- * where the key maps to the value very simply.
13
- *
14
- * It takes a work function that should generate a new value
15
- * for a given key when called. It will be called when the key
16
- * is not found in the cache.
17
- *
18
- * It keeps track of the number of hits, misses, and ejections
19
- * in DEBUG envs, which is useful for tuning the cache size.
20
- *
21
- * This is an internal utility class for use by this module
22
- * and by `@warp-drive-mirror/utilities/string`. It is not intended
23
- * for use outside of these modules at this time.
24
- *
25
- * @private
26
- */
27
- class LRUCache {
28
- // debug stats
29
-
30
- constructor(doWork, size) {
31
- this.size = size || DEFAULT_MAX_CACHE_SIZE;
32
- this.state = new Map();
33
- this.doWork = doWork;
34
- }
35
- get(key) {
36
- const value = this.state.get(key);
37
- if (value) {
38
- this.state.delete(key);
39
- this.state.set(key, value);
40
- return value;
41
- }
42
- const newValue = this.doWork(key);
43
- this.set(key, newValue);
44
- return newValue;
45
- }
46
- set(key, value) {
47
- if (this.state.size === this.size) {
48
- for (const [k] of this.state) {
49
- this.state.delete(k);
50
- break;
51
- }
52
- }
53
- this.state.set(key, value);
54
- }
55
- clear() {
56
- this.state.clear();
57
- }
58
- }
5
+ * An LRUCache implementation with upsert semantics.
6
+ *
7
+ * This implementation is *not* generic, but focuses on
8
+ * performance tuning for the string transformation cases
9
+ * where the key maps to the value very simply.
10
+ *
11
+ * It takes a work function that should generate a new value
12
+ * for a given key when called. It will be called when the key
13
+ * is not found in the cache.
14
+ *
15
+ * It keeps track of the number of hits, misses, and ejections
16
+ * in DEBUG envs, which is useful for tuning the cache size.
17
+ *
18
+ * This is an internal utility class for use by this module
19
+ * and by `@warp-drive-mirror/utilities/string`. It is not intended
20
+ * for use outside of these modules at this time.
21
+ *
22
+ * @private
23
+ */
24
+ var LRUCache = class {
25
+ constructor(doWork, size) {
26
+ this.size = size || DEFAULT_MAX_CACHE_SIZE;
27
+ this.state = /* @__PURE__ */ new Map();
28
+ this.doWork = doWork;
29
+ }
30
+ get(key) {
31
+ const value = this.state.get(key);
32
+ if (value) {
33
+ this.state.delete(key);
34
+ this.state.set(key, value);
35
+ return value;
36
+ }
37
+ const newValue = this.doWork(key);
38
+ this.set(key, newValue);
39
+ return newValue;
40
+ }
41
+ set(key, value) {
42
+ if (this.state.size === this.size) for (const [k] of this.state) {
43
+ this.state.delete(k);
44
+ break;
45
+ }
46
+ this.state.set(key, value);
47
+ }
48
+ clear() {
49
+ this.state.clear();
50
+ }
51
+ };
59
52
  const STRING_DASHERIZE_REGEXP = /[ _]/g;
60
53
  const STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
61
- const STRING_DASHERIZE_CACHE = new LRUCache(key => key.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase().replace(STRING_DASHERIZE_REGEXP, '-'));
62
-
63
54
  /**
64
- * This is an internal utility function that converts a string
65
- * to a dasherized format. Library consumers should use the
66
- * re-exported version from `@warp-drive-mirror/utilities/string` instead.
67
- *
68
- * This version is only in this location to support a deprecated
69
- * behavior in the core package and will be removed in a future.
70
- *
71
- * @private
72
- */
55
+ * The {@link LRUCache} backing {@link dasherize}, keyed by the original
56
+ * (un-dasherized) string.
57
+ *
58
+ * @private
59
+ */
60
+ const STRING_DASHERIZE_CACHE = new LRUCache((key) => key.replace(STRING_DECAMELIZE_REGEXP, "$1_$2").toLowerCase().replace(STRING_DASHERIZE_REGEXP, "-"));
61
+ /**
62
+ * This is an internal utility function that converts a string
63
+ * to a dasherized format. Library consumers should use the
64
+ * re-exported version from `@warp-drive-mirror/utilities/string` instead.
65
+ *
66
+ * This version is only in this location to support a deprecated
67
+ * behavior in the core package and will be removed in a future.
68
+ *
69
+ * @private
70
+ */
73
71
  function dasherize$1(str) {
74
- return STRING_DASHERIZE_CACHE.get(str);
72
+ return STRING_DASHERIZE_CACHE.get(str);
75
73
  }
76
74
 
75
+ //#endregion
76
+ //#region src/-private/string/inflections.ts
77
77
  const defaultRules = {
78
- 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']],
79
- singular: [[/s$/i, ''], [/(ss)$/i, '$1'], [/(n)ews$/i, '$1ews'], [/([ti])a$/i, '$1um'], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'], [/(^analy)(sis|ses)$/i, '$1sis'], [/([^f])ves$/i, '$1fe'], [/(hive)s$/i, '$1'], [/(tive)s$/i, '$1'], [/([lr])ves$/i, '$1f'], [/([^aeiouy]|qu)ies$/i, '$1y'], [/(s)eries$/i, '$1eries'], [/(m)ovies$/i, '$1ovie'], [/(x|ch|ss|sh)es$/i, '$1'], [/^(m|l)ice$/i, '$1ouse'], [/(bus)(es)?$/i, '$1'], [/(o)es$/i, '$1'], [/(shoe)s$/i, '$1'], [/(cris|test)(is|es)$/i, '$1is'], [/^(a)x[ie]s$/i, '$1xis'], [/(octop|vir)(us|i)$/i, '$1us'], [/(alias|status|bonus)(es)?$/i, '$1'], [/^(ox)en/i, '$1'], [/(vert|ind)ices$/i, '$1ex'], [/(matr)ices$/i, '$1ix'], [/(quiz)zes$/i, '$1'], [/(database)s$/i, '$1']],
80
- irregularPairs: [['person', 'people'], ['man', 'men'], ['child', 'children'], ['sex', 'sexes'], ['move', 'moves'], ['cow', 'kine'], ['zombie', 'zombies']],
81
- uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police']
78
+ plurals: [
79
+ [/$/, "s"],
80
+ [/s$/i, "s"],
81
+ [/^(ax|test)is$/i, "$1es"],
82
+ [/(octop|vir)us$/i, "$1i"],
83
+ [/(octop|vir)i$/i, "$1i"],
84
+ [/(alias|status|bonus)$/i, "$1es"],
85
+ [/(tu|bu)s$/i, "$1ses"],
86
+ [/(buffal|tomat)o$/i, "$1oes"],
87
+ [/([ti])um$/i, "$1a"],
88
+ [/([ti])a$/i, "$1a"],
89
+ [/sis$/i, "ses"],
90
+ [/(?:([^f])fe|([lr])f)$/i, "$1$2ves"],
91
+ [/(hive)$/i, "$1s"],
92
+ [/([^aeiouy]|qu)y$/i, "$1ies"],
93
+ [/(x|ch|ss|sh)$/i, "$1es"],
94
+ [/(matr|vert|ind)(?:ix|ex)$/i, "$1ices"],
95
+ [/^(m|l)ouse$/i, "$1ice"],
96
+ [/^(m|l)ice$/i, "$1ice"],
97
+ [/^(ox)$/i, "$1en"],
98
+ [/^(oxen)$/i, "$1"],
99
+ [/(quiz)$/i, "$1zes"]
100
+ ],
101
+ singular: [
102
+ [/s$/i, ""],
103
+ [/(ss)$/i, "$1"],
104
+ [/(n)ews$/i, "$1ews"],
105
+ [/([ti])a$/i, "$1um"],
106
+ [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, "$1sis"],
107
+ [/(^analy)(sis|ses)$/i, "$1sis"],
108
+ [/([^f])ves$/i, "$1fe"],
109
+ [/(hive)s$/i, "$1"],
110
+ [/(tive)s$/i, "$1"],
111
+ [/([lr])ves$/i, "$1f"],
112
+ [/([^aeiouy]|qu)ies$/i, "$1y"],
113
+ [/(s)eries$/i, "$1eries"],
114
+ [/(m)ovies$/i, "$1ovie"],
115
+ [/(x|ch|ss|sh)es$/i, "$1"],
116
+ [/^(m|l)ice$/i, "$1ouse"],
117
+ [/(tus|bus)(es)?$/i, "$1"],
118
+ [/(o)es$/i, "$1"],
119
+ [/(shoe)s$/i, "$1"],
120
+ [/(cris|test)(is|es)$/i, "$1is"],
121
+ [/^(a)x[ie]s$/i, "$1xis"],
122
+ [/(octop|vir)(us|i)$/i, "$1us"],
123
+ [/(alias|status|bonus)(es)?$/i, "$1"],
124
+ [/^(ox)en/i, "$1"],
125
+ [/(vert|ind)ices$/i, "$1ex"],
126
+ [/(matr)ices$/i, "$1ix"],
127
+ [/(quiz)zes$/i, "$1"],
128
+ [/(database)s$/i, "$1"]
129
+ ],
130
+ irregularPairs: [
131
+ ["person", "people"],
132
+ ["man", "men"],
133
+ ["child", "children"],
134
+ ["sex", "sexes"],
135
+ ["move", "moves"],
136
+ ["cow", "kine"],
137
+ ["zombie", "zombies"]
138
+ ],
139
+ uncountable: [
140
+ "equipment",
141
+ "information",
142
+ "rice",
143
+ "money",
144
+ "species",
145
+ "series",
146
+ "fish",
147
+ "sheep",
148
+ "jeans",
149
+ "police"
150
+ ]
82
151
  };
83
152
 
84
- // eslint-disable-next-line no-useless-escape
153
+ //#endregion
154
+ //#region src/-private/string/transform.ts
85
155
  const STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
86
156
  const STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
87
- 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()));
157
+ const CAMELIZE_CACHE = new LRUCache((key) => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : "").replace(STRING_CAMELIZE_REGEXP_2, (match) => match.toLowerCase()));
88
158
  const STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
89
- // eslint-disable-next-line no-useless-escape
90
159
  const STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
91
- const UNDERSCORE_CACHE = new LRUCache(str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase());
160
+ const UNDERSCORE_CACHE = new LRUCache((str) => str.replace(STRING_UNDERSCORE_REGEXP_1, "$1_$2").replace(STRING_UNDERSCORE_REGEXP_2, "_").toLowerCase());
92
161
  const STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g;
93
- const CAPITALIZE_CACHE = new LRUCache(str => str.replace(STRING_CAPITALIZE_REGEXP, (match /*, separator, chr */) => match.toUpperCase()));
94
-
162
+ const CAPITALIZE_CACHE = new LRUCache((str) => str.replace(STRING_CAPITALIZE_REGEXP, (match) => match.toUpperCase()));
95
163
  /**
96
- * Replaces underscores, spaces, or camelCase with dashes.
97
- *
98
- * ```js
99
- * import { dasherize } from '@warp-drive-mirror/utilities/string';
100
- *
101
- * dasherize('innerHTML'); // 'inner-html'
102
- * dasherize('action_name'); // 'action-name'
103
- * dasherize('css-class-name'); // 'css-class-name'
104
- * dasherize('my favorite items'); // 'my-favorite-items'
105
- * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
106
- * ```
107
- *
108
- * @public
109
- * @since 4.13.0
110
- */
164
+ * Replaces underscores, spaces, or camelCase with dashes.
165
+ *
166
+ * ```js
167
+ * import { dasherize } from '@warp-drive-mirror/utilities/string';
168
+ *
169
+ * dasherize('innerHTML'); // 'inner-html'
170
+ * dasherize('action_name'); // 'action-name'
171
+ * dasherize('css-class-name'); // 'css-class-name'
172
+ * dasherize('my favorite items'); // 'my-favorite-items'
173
+ * dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice'
174
+ * ```
175
+ *
176
+ * @public
177
+ * @since 4.13.0
178
+ */
111
179
  const dasherize = dasherize$1;
112
-
113
180
  /**
114
- * Returns the lowerCamelCase form of a string.
115
- *
116
- * ```js
117
- * import { camelize } from '@warp-drive-mirror/utilities/string';
118
- *
119
- * camelize('innerHTML'); // 'innerHTML'
120
- * camelize('action_name'); // 'actionName'
121
- * camelize('css-class-name'); // 'cssClassName'
122
- * camelize('my favorite items'); // 'myFavoriteItems'
123
- * camelize('My Favorite Items'); // 'myFavoriteItems'
124
- * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
125
- * ```
126
- *
127
- * @public
128
- * @since 4.13.0
129
- */
181
+ * Returns the lowerCamelCase form of a string.
182
+ *
183
+ * ```js
184
+ * import { camelize } from '@warp-drive-mirror/utilities/string';
185
+ *
186
+ * camelize('innerHTML'); // 'innerHTML'
187
+ * camelize('action_name'); // 'actionName'
188
+ * camelize('css-class-name'); // 'cssClassName'
189
+ * camelize('my favorite items'); // 'myFavoriteItems'
190
+ * camelize('My Favorite Items'); // 'myFavoriteItems'
191
+ * camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice'
192
+ * ```
193
+ *
194
+ * @public
195
+ * @since 4.13.0
196
+ */
130
197
  function camelize(str) {
131
- return CAMELIZE_CACHE.get(str);
198
+ return CAMELIZE_CACHE.get(str);
132
199
  }
133
-
134
200
  /**
135
- * Returns the lower\_case\_and\_underscored form of a string.
136
- *
137
- * ```js
138
- * import { underscore } from '@warp-drive-mirror/utilities/string';
139
- *
140
- * underscore('innerHTML'); // 'inner_html'
141
- * underscore('action_name'); // 'action_name'
142
- * underscore('css-class-name'); // 'css_class_name'
143
- * underscore('my favorite items'); // 'my_favorite_items'
144
- * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
145
- * ```
146
- *
147
- * @public
148
- * @since 4.13.0
149
- */
201
+ * Returns the lower\_case\_and\_underscored form of a string.
202
+ *
203
+ * ```js
204
+ * import { underscore } from '@warp-drive-mirror/utilities/string';
205
+ *
206
+ * underscore('innerHTML'); // 'inner_html'
207
+ * underscore('action_name'); // 'action_name'
208
+ * underscore('css-class-name'); // 'css_class_name'
209
+ * underscore('my favorite items'); // 'my_favorite_items'
210
+ * underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice'
211
+ * ```
212
+ *
213
+ * @public
214
+ * @since 4.13.0
215
+ */
150
216
  function underscore(str) {
151
- return UNDERSCORE_CACHE.get(str);
217
+ return UNDERSCORE_CACHE.get(str);
152
218
  }
153
-
154
219
  /**
155
- * Returns the Capitalized form of a string
156
- *
157
- * ```js
158
- * import { capitalize } from '@warp-drive-mirror/utilities/string';
159
- *
160
- * capitalize('innerHTML') // 'InnerHTML'
161
- * capitalize('action_name') // 'Action_name'
162
- * capitalize('css-class-name') // 'Css-class-name'
163
- * capitalize('my favorite items') // 'My favorite items'
164
- * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
165
- * ```
166
- *
167
- * @public
168
- * @since 4.13.0
169
- */
220
+ * Returns the Capitalized form of a string
221
+ *
222
+ * ```js
223
+ * import { capitalize } from '@warp-drive-mirror/utilities/string';
224
+ *
225
+ * capitalize('innerHTML') // 'InnerHTML'
226
+ * capitalize('action_name') // 'Action_name'
227
+ * capitalize('css-class-name') // 'Css-class-name'
228
+ * capitalize('my favorite items') // 'My favorite items'
229
+ * capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice'
230
+ * ```
231
+ *
232
+ * @public
233
+ * @since 4.13.0
234
+ */
170
235
  function capitalize(str) {
171
- return CAPITALIZE_CACHE.get(str);
236
+ return CAPITALIZE_CACHE.get(str);
172
237
  }
173
-
174
238
  /**
175
- * Sets the maximum size of the LRUCache for all string transformation functions.
176
- * The default size is 10,000.
177
- *
178
- * @public
179
- * @since 4.13.0
180
- */
239
+ * Sets the maximum size of the LRUCache for all string transformation functions.
240
+ * The default size is 10,000.
241
+ *
242
+ * @public
243
+ * @since 4.13.0
244
+ */
181
245
  function setMaxLRUCacheSize(size) {
182
- CAMELIZE_CACHE.size = size;
183
- UNDERSCORE_CACHE.size = size;
184
- CAPITALIZE_CACHE.size = size;
185
- STRING_DASHERIZE_CACHE.size = size;
246
+ CAMELIZE_CACHE.size = size;
247
+ UNDERSCORE_CACHE.size = size;
248
+ CAPITALIZE_CACHE.size = size;
249
+ STRING_DASHERIZE_CACHE.size = size;
186
250
  }
187
251
 
252
+ //#endregion
253
+ //#region src/-private/string/inflect.ts
188
254
  const BLANK_REGEX = /^\s*$/;
189
255
  const LAST_WORD_DASHED_REGEX = /([\w/-]+[_/\s-])([a-z\d]+$)/;
190
256
  const LAST_WORD_CAMELIZED_REGEX = /([\w/\s-]+)([A-Z][a-z\d]*$)/;
191
257
  const CAMELIZED_REGEX = /[A-Z][a-z\d]*$/;
192
- const SINGULARS = new LRUCache(word => {
193
- return _singularize(word);
258
+ const SINGULARS = new LRUCache((word) => {
259
+ return _singularize(word);
194
260
  });
195
- const PLURALS = new LRUCache(word => {
196
- return _pluralize(word);
261
+ const PLURALS = new LRUCache((word) => {
262
+ return _pluralize(word);
197
263
  });
198
264
  const UNCOUNTABLE = new Set(defaultRules.uncountable);
199
- const IRREGULAR = new Map();
200
- const INVERSE_IRREGULAR = new Map();
265
+ const IRREGULAR = /* @__PURE__ */ new Map();
266
+ const INVERSE_IRREGULAR = /* @__PURE__ */ new Map();
201
267
  const SINGULAR_RULES = new Map(defaultRules.singular.reverse());
202
268
  const PLURAL_RULES = new Map(defaultRules.plurals.reverse());
203
-
204
269
  /**
205
- * Marks a word as uncountable. Uncountable words are not pluralized
206
- * or singularized.
207
- *
208
- * @public
209
- * @since 4.13.0
210
- */
270
+ * Marks a word as uncountable. Uncountable words are not pluralized
271
+ * or singularized.
272
+ *
273
+ * @public
274
+ * @since 4.13.0
275
+ */
211
276
  function uncountable(word) {
212
- UNCOUNTABLE.add(word.toLowerCase());
277
+ UNCOUNTABLE.add(word.toLowerCase());
213
278
  }
214
-
215
279
  /**
216
- * Marks a list of words as uncountable. Uncountable words are not pluralized
217
- * or singularized.
218
- *
219
- * @public
220
- * @since 4.13.0
221
- */
280
+ * Marks a list of words as uncountable. Uncountable words are not pluralized
281
+ * or singularized.
282
+ *
283
+ * @public
284
+ * @since 4.13.0
285
+ */
222
286
  function loadUncountable(uncountables) {
223
- uncountables.forEach(word => {
224
- uncountable(word);
225
- });
287
+ uncountables.forEach((word) => {
288
+ uncountable(word);
289
+ });
226
290
  }
227
-
228
291
  /**
229
- * Marks a word as irregular. Irregular words have unique
230
- * pluralization and singularization rules.
231
- *
232
- * @public
233
- * @since 4.13.0
234
- */
292
+ * Marks a word as irregular. Irregular words have unique
293
+ * pluralization and singularization rules.
294
+ *
295
+ * @public
296
+ * @since 4.13.0
297
+ */
235
298
  function irregular(single, plur) {
236
- //pluralizing
237
- IRREGULAR.set(single.toLowerCase(), plur);
238
- IRREGULAR.set(plur.toLowerCase(), plur);
239
-
240
- //singularizing
241
- INVERSE_IRREGULAR.set(plur.toLowerCase(), single);
242
- INVERSE_IRREGULAR.set(single.toLowerCase(), single);
299
+ IRREGULAR.set(single.toLowerCase(), plur);
300
+ IRREGULAR.set(plur.toLowerCase(), plur);
301
+ INVERSE_IRREGULAR.set(plur.toLowerCase(), single);
302
+ INVERSE_IRREGULAR.set(single.toLowerCase(), single);
243
303
  }
244
-
245
304
  /**
246
- * Marks a list of word pairs as irregular. Irregular words have unique
247
- * pluralization and singularization rules.
248
- *
249
- * @public
250
- * @since 4.13.0
251
- */
305
+ * Marks a list of word pairs as irregular. Irregular words have unique
306
+ * pluralization and singularization rules.
307
+ *
308
+ * @public
309
+ * @since 4.13.0
310
+ */
252
311
  function loadIrregular(irregularPairs) {
253
- irregularPairs.forEach(pair => {
254
- //pluralizing
255
- IRREGULAR.set(pair[0].toLowerCase(), pair[1]);
256
- IRREGULAR.set(pair[1].toLowerCase(), pair[1]);
257
-
258
- //singularizing
259
- INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);
260
- INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);
261
- });
312
+ irregularPairs.forEach((pair) => {
313
+ IRREGULAR.set(pair[0].toLowerCase(), pair[1]);
314
+ IRREGULAR.set(pair[1].toLowerCase(), pair[1]);
315
+ INVERSE_IRREGULAR.set(pair[1].toLowerCase(), pair[0]);
316
+ INVERSE_IRREGULAR.set(pair[0].toLowerCase(), pair[0]);
317
+ });
262
318
  }
263
319
  loadIrregular(defaultRules.irregularPairs);
264
-
265
320
  /**
266
- * Clears the caches for singularize and pluralize.
267
- *
268
- * @public
269
- * @since 4.13.0
270
- */
321
+ * Clears the caches for singularize and pluralize.
322
+ *
323
+ * @public
324
+ * @since 4.13.0
325
+ */
271
326
  function clear() {
272
- SINGULARS.clear();
273
- PLURALS.clear();
327
+ SINGULARS.clear();
328
+ PLURALS.clear();
274
329
  }
275
-
276
330
  /**
277
- * Resets the inflection rules to the defaults.
278
- *
279
- * @public
280
- * @since 4.13.0
281
- */
331
+ * Resets the inflection rules to the defaults.
332
+ *
333
+ * @public
334
+ * @since 4.13.0
335
+ */
282
336
  function resetToDefaults() {
283
- clearRules();
284
- defaultRules.uncountable.forEach(v => UNCOUNTABLE.add(v));
285
- defaultRules.singular.forEach(v => SINGULAR_RULES.set(v[0], v[1]));
286
- defaultRules.plurals.forEach(v => PLURAL_RULES.set(v[0], v[1]));
287
- loadIrregular(defaultRules.irregularPairs);
337
+ clearRules();
338
+ defaultRules.uncountable.forEach((v) => UNCOUNTABLE.add(v));
339
+ defaultRules.singular.forEach((v) => SINGULAR_RULES.set(v[0], v[1]));
340
+ defaultRules.plurals.forEach((v) => PLURAL_RULES.set(v[0], v[1]));
341
+ loadIrregular(defaultRules.irregularPairs);
288
342
  }
289
-
290
343
  /**
291
- * Clears all inflection rules
292
- * and resets the caches for singularize and pluralize.
293
- *
294
- * @public
295
- * @since 4.13.0
296
- */
344
+ * Clears all inflection rules
345
+ * and resets the caches for singularize and pluralize.
346
+ *
347
+ * @public
348
+ * @since 4.13.0
349
+ */
297
350
  function clearRules() {
298
- SINGULARS.clear();
299
- PLURALS.clear();
300
- UNCOUNTABLE.clear();
301
- IRREGULAR.clear();
302
- INVERSE_IRREGULAR.clear();
303
- SINGULAR_RULES.clear();
304
- PLURAL_RULES.clear();
351
+ SINGULARS.clear();
352
+ PLURALS.clear();
353
+ UNCOUNTABLE.clear();
354
+ IRREGULAR.clear();
355
+ INVERSE_IRREGULAR.clear();
356
+ SINGULAR_RULES.clear();
357
+ PLURAL_RULES.clear();
305
358
  }
306
-
307
359
  /**
308
- * Singularizes a word.
309
- *
310
- * @public
311
- * @since 4.13.0
312
- */
360
+ * Singularizes a word.
361
+ *
362
+ * @public
363
+ * @since 4.13.0
364
+ */
313
365
  function singularize(word) {
314
- if (!word) return '';
315
- return SINGULARS.get(word);
366
+ if (!word) return "";
367
+ return SINGULARS.get(word);
316
368
  }
317
-
318
369
  /**
319
- * Pluralizes a word.
320
- *
321
- * @public
322
- * @since 4.13.0
323
- */
370
+ * Pluralizes a word.
371
+ *
372
+ * @public
373
+ * @since 4.13.0
374
+ */
324
375
  function pluralize(word) {
325
- if (!word) return '';
326
- return PLURALS.get(word);
376
+ if (!word) return "";
377
+ return PLURALS.get(word);
327
378
  }
328
379
  function unshiftMap(v, map) {
329
- // reorder
330
- const rules = [v, ...map.entries()];
331
- map.clear();
332
- rules.forEach(rule => {
333
- map.set(rule[0], rule[1]);
334
- });
380
+ const rules = [v, ...map.entries()];
381
+ map.clear();
382
+ rules.forEach((rule) => {
383
+ map.set(rule[0], rule[1]);
384
+ });
335
385
  }
336
-
337
386
  /**
338
- * Adds a pluralization rule.
339
- *
340
- * @public
341
- * @since 4.13.0
342
- */
387
+ * Adds a pluralization rule.
388
+ *
389
+ * @public
390
+ * @since 4.13.0
391
+ */
343
392
  function plural(regex, string) {
344
- // rule requires reordering if exists, so remove it first
345
- if (PLURAL_RULES.has(regex)) {
346
- PLURAL_RULES.delete(regex);
347
- }
348
-
349
- // reorder
350
- unshiftMap([regex, string], PLURAL_RULES);
393
+ if (PLURAL_RULES.has(regex)) PLURAL_RULES.delete(regex);
394
+ unshiftMap([regex, string], PLURAL_RULES);
351
395
  }
352
-
353
396
  /**
354
- * Adds a singularization rule.
355
- *
356
- * @public
357
- * @since 4.13.0
358
- */
397
+ * Adds a singularization rule.
398
+ *
399
+ * @public
400
+ * @since 4.13.0
401
+ */
359
402
  function singular(regex, string) {
360
- // rule requires reordering if exists, so remove it first
361
- if (SINGULAR_RULES.has(regex)) {
362
- SINGULAR_RULES.delete(regex);
363
- }
364
-
365
- // reorder
366
- unshiftMap([regex, string], SINGULAR_RULES);
403
+ if (SINGULAR_RULES.has(regex)) SINGULAR_RULES.delete(regex);
404
+ unshiftMap([regex, string], SINGULAR_RULES);
367
405
  }
368
406
  function _pluralize(word) {
369
- return inflect(word, PLURAL_RULES, IRREGULAR);
407
+ return inflect(word, PLURAL_RULES, IRREGULAR);
370
408
  }
371
409
  function _singularize(word) {
372
- return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);
410
+ return inflect(word, SINGULAR_RULES, INVERSE_IRREGULAR);
373
411
  }
374
412
  function inflect(word, typeRules, irregulars) {
375
- // empty strings
376
- const isBlank = !word || BLANK_REGEX.test(word);
377
- if (isBlank) {
378
- return word;
379
- }
380
-
381
- // basic uncountables
382
- const lowercase = word.toLowerCase();
383
- if (UNCOUNTABLE.has(lowercase)) {
384
- return word;
385
- }
386
-
387
- // adv uncountables
388
- const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);
389
- const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;
390
- if (lastWord && UNCOUNTABLE.has(lastWord)) {
391
- return word;
392
- }
393
-
394
- // handle irregulars
395
- const isCamelized = CAMELIZED_REGEX.test(word);
396
- for (let [rule, substitution] of irregulars) {
397
- if (lowercase.match(rule + '$')) {
398
- if (isCamelized && lastWord && irregulars.has(lastWord)) {
399
- substitution = capitalize(substitution);
400
- rule = capitalize(rule);
401
- }
402
- return word.replace(new RegExp(rule, 'i'), substitution);
403
- }
404
- }
405
-
406
- // do the actual inflection
407
- for (const [rule, substitution] of typeRules) {
408
- if (rule.test(word)) {
409
- return word.replace(rule, substitution);
410
- }
411
- }
412
- return word;
413
+ if (!word || BLANK_REGEX.test(word)) return word;
414
+ const lowercase = word.toLowerCase();
415
+ if (UNCOUNTABLE.has(lowercase)) return word;
416
+ const wordSplit = LAST_WORD_DASHED_REGEX.exec(word) || LAST_WORD_CAMELIZED_REGEX.exec(word);
417
+ const lastWord = wordSplit ? wordSplit[2].toLowerCase() : null;
418
+ if (lastWord && UNCOUNTABLE.has(lastWord)) return word;
419
+ const isCamelized = CAMELIZED_REGEX.test(word);
420
+ for (let [rule, substitution] of irregulars) if (lowercase.match(rule + "$")) {
421
+ if (isCamelized && lastWord && irregulars.has(lastWord)) {
422
+ substitution = capitalize(substitution);
423
+ rule = capitalize(rule);
424
+ }
425
+ return word.replace(new RegExp(rule, "i"), substitution);
426
+ }
427
+ for (const [rule, substitution] of typeRules) if (rule.test(word)) return word.replace(rule, substitution);
428
+ return word;
413
429
  }
414
430
 
431
+ //#endregion
415
432
  exports.camelize = camelize;
416
433
  exports.capitalize = capitalize;
417
434
  exports.clear = clear;
@@ -428,3 +445,4 @@ exports.singular = singular;
428
445
  exports.singularize = singularize;
429
446
  exports.uncountable = uncountable;
430
447
  exports.underscore = underscore;
448
+ //# sourceMappingURL=string.cjs.map