@webdeveric/utils 0.17.1 → 0.19.0

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 (51) hide show
  1. package/dist/cjs/capitalize.js +6 -0
  2. package/dist/cjs/capitalize.js.map +1 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/normalize.js.map +1 -1
  6. package/dist/cjs/toPascalCase.js +9 -20
  7. package/dist/cjs/toPascalCase.js.map +1 -1
  8. package/dist/cjs/type-assertion.js +185 -10
  9. package/dist/cjs/type-assertion.js.map +1 -1
  10. package/dist/cjs/type-predicate.js +67 -18
  11. package/dist/cjs/type-predicate.js.map +1 -1
  12. package/dist/mjs/capitalize.js +2 -0
  13. package/dist/mjs/capitalize.js.map +1 -0
  14. package/dist/mjs/index.js +1 -0
  15. package/dist/mjs/index.js.map +1 -1
  16. package/dist/mjs/normalize.js.map +1 -1
  17. package/dist/mjs/toPascalCase.js +9 -20
  18. package/dist/mjs/toPascalCase.js.map +1 -1
  19. package/dist/mjs/type-assertion.js +155 -9
  20. package/dist/mjs/type-assertion.js.map +1 -1
  21. package/dist/mjs/type-predicate.js +46 -14
  22. package/dist/mjs/type-predicate.js.map +1 -1
  23. package/dist/types/capitalize.d.ts +2 -0
  24. package/dist/types/capitalize.d.ts.map +1 -0
  25. package/dist/types/compose.d.ts +1 -1
  26. package/dist/types/compose.d.ts.map +1 -1
  27. package/dist/types/convert.d.ts +4 -4
  28. package/dist/types/convert.d.ts.map +1 -1
  29. package/dist/types/index.d.ts +1 -0
  30. package/dist/types/index.d.ts.map +1 -1
  31. package/dist/types/normalize.d.ts +6 -7
  32. package/dist/types/normalize.d.ts.map +1 -1
  33. package/dist/types/toPascalCase.d.ts +2 -1
  34. package/dist/types/toPascalCase.d.ts.map +1 -1
  35. package/dist/types/type-assertion.d.ts +35 -4
  36. package/dist/types/type-assertion.d.ts.map +1 -1
  37. package/dist/types/type-predicate.d.ts +21 -4
  38. package/dist/types/type-predicate.d.ts.map +1 -1
  39. package/dist/types/types.d.ts +20 -11
  40. package/dist/types/types.d.ts.map +1 -1
  41. package/dist/types/until.d.ts +7 -7
  42. package/dist/types/until.d.ts.map +1 -1
  43. package/package.json +4 -5
  44. package/src/capitalize.ts +1 -0
  45. package/src/convert.ts +1 -1
  46. package/src/index.ts +1 -0
  47. package/src/normalize.ts +1 -3
  48. package/src/toPascalCase.ts +14 -24
  49. package/src/type-assertion.ts +309 -10
  50. package/src/type-predicate.ts +75 -23
  51. package/src/types.ts +23 -1
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capitalize = void 0;
4
+ const capitalize = (word) => word.substring(0, 1).toUpperCase() + word.substring(1);
5
+ exports.capitalize = capitalize;
6
+ //# sourceMappingURL=capitalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../src/capitalize.ts"],"names":[],"mappings":";;;AAAO,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAA9F,QAAA,UAAU,cAAoF"}
package/dist/cjs/index.js CHANGED
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./asArray.js"), exports);
18
+ __exportStar(require("./capitalize.js"), exports);
18
19
  __exportStar(require("./clamp.js"), exports);
19
20
  __exportStar(require("./compose.js"), exports);
20
21
  __exportStar(require("./convert.js"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,6CAA2B;AAC3B,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,2DAAyC;AACzC,mDAAiC;AACjC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,+CAA6B;AAC7B,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,mDAAiC;AACjC,oDAAkC;AAClC,+CAA6B;AAC7B,uDAAqC;AACrC,iDAA+B;AAC/B,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC;AAChC,6CAA2B;AAC3B,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,2DAAyC;AACzC,mDAAiC;AACjC,mDAAiC;AACjC,kDAAgC;AAChC,wDAAsC;AACtC,+CAA6B;AAC7B,+CAA6B;AAC7B,gDAA8B;AAC9B,mDAAiC;AACjC,iDAA+B;AAC/B,mDAAiC;AACjC,oDAAkC;AAClC,+CAA6B;AAC7B,uDAAqC;AACrC,iDAA+B;AAC/B,6CAA2B;AAC3B,mDAAiC;AACjC,6CAA2B"}
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.js","sourceRoot":"","sources":["../../src/normalize.ts"],"names":[],"mappings":";;;;;;AAAA,wEAAyC;AAIzC,+DAAyD;AACzD,+CAAyC;AAwDzC,SAAgB,SAAS,CACvB,KAAqB,EACrB,WAAmD,EACnD,kBAAyD,GAAc,EAAE,CAAC,CAAC,EAAE,CAAC;IAE9E,MAAM,OAAO,GAAG,IAAA,0BAAS,EAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,OAAO,GAAwC,MAAM,CAAC,IAAI,CAAC;QAC/D,QAAQ,EAAE,KAAK;QACf,OAAO;QACP,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC;KAC1C,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,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AM,CAAC,IAAI,CAAC;QAC/D,QAAQ,EAAE,KAAK;QACf,OAAO;QACP,IAAI,EAAE,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC;KAC1C,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,CACX,aAA4B,EAC5B,kBAAoE,EACrD,EAAE;QACjB,IAAI,OAAO,kBAAkB,KAAK,UAAU,EAAE;YAC5C,OAAO,kBAAkB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;SACnD;QAED,IAAI,OAAO,kBAAkB,KAAK,QAAQ,IAAI,kBAAkB,KAAK,IAAI,EAAE;YACzE,IAAI,OAAO,aAAa,KAAK,QAAQ,IAAI,aAAa,KAAK,IAAI,EAAE;gBAC/D,OAAO,IAAA,sCAAgB,EAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBAC/D,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;oBAC5C,yFAAyF;oBACzF,MAAM,KAAK,GACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,WAAW,IAAI,IAAA,sBAAQ,EAAC,WAAW,CAAC;wBACvD,CAAC,CAAE,EAAoD;wBACvD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAEhB,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;oBAErC,OAAO,IAAI,CAAC;gBACd,CAAC,EAAE,aAAa,CAAC,CAAC;aACnB;SACF;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC;AA1CD,8BA0CC"}
@@ -1,34 +1,23 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toPascalCase = void 0;
4
+ const capitalize_js_1 = require("./capitalize.js");
4
5
  const getType_js_1 = require("./getType.js");
5
6
  function toPascalCase(text, customWords) {
6
- let words = String(text).match(/[A-Z][a-z']+|\d+|[a-z']+/g);
7
- if (!words) {
7
+ const words = String(text).match(/[A-Z][a-z']+|\d+|[a-z']+/g);
8
+ if (words === null) {
8
9
  return '';
9
10
  }
10
- // Remove apostrophes then uppercase the first letter of each word.
11
- words = words.map(word => {
12
- const fixedWord = word.replace(/'/g, '');
13
- return fixedWord.substring(0, 1).toUpperCase() + fixedWord.substring(1);
14
- });
11
+ let fixedWords = words.map(word => (0, capitalize_js_1.capitalize)(word.replace(/'/g, '')));
15
12
  if (customWords && (0, getType_js_1.getType)(customWords) === 'Object') {
16
- const replacements = Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]);
17
- if (replacements.length) {
13
+ const replacements = new Map(Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]));
14
+ if (replacements.size) {
18
15
  // This takes a single word and returns the first matching replacement, if any.
19
- const replaceCustomWords = (word) => {
20
- const lowerWord = word.toLowerCase();
21
- for (const [key, value] of replacements) {
22
- if (key === lowerWord && typeof value === 'string') {
23
- return value;
24
- }
25
- }
26
- return word;
27
- };
28
- words = words.map(replaceCustomWords);
16
+ const replaceCustomWords = (word) => { var _a; return (_a = replacements.get(word.toLowerCase())) !== null && _a !== void 0 ? _a : word; };
17
+ fixedWords = fixedWords.map(replaceCustomWords);
29
18
  }
30
19
  }
31
- return words.join('');
20
+ return fixedWords.join('');
32
21
  }
33
22
  exports.toPascalCase = toPascalCase;
34
23
  //# sourceMappingURL=toPascalCase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toPascalCase.js","sourceRoot":"","sources":["../../src/toPascalCase.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAEvC,SAAgB,YAAY,CAAC,IAAY,EAAE,WAAoC;IAC7E,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAE5D,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAA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B,YAAY,CAAC,IAAY,EAAE,WAA0B;IACnE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAE9D,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,EAAE,CAAC;KACX;IAED,IAAI,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAA,0BAAU,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAEvE,IAAI,WAAW,IAAI,IAAA,oBAAO,EAAC,WAAW,CAAC,KAAK,QAAQ,EAAE;QACpD,MAAM,YAAY,GAAG,IAAI,GAAG,CAC1B,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAgC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC,CAC7G,CAAC;QAEF,IAAI,YAAY,CAAC,IAAI,EAAE;YACrB,+EAA+E;YAC/E,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAU,EAAE,WAAC,OAAA,MAAA,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,mCAAI,IAAI,CAAA,EAAA,CAAC;YAElG,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;SACjD;KACF;IAED,OAAO,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAvBD,oCAuBC"}
@@ -1,23 +1,198 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertIsNumericValueArray = exports.assertIsFiniteNumber = exports.assertIsInteger = void 0;
3
+ exports.assertExhaustive = exports.assertIsUndefined = exports.assertIsSymbol = exports.assertIsStringWithLength = exports.assertIsStringRecord = exports.assertIsStringMatching = exports.assertIsString = exports.assertIsPropertyKey = exports.assertIsPromiseRejectedResult = exports.assertIsPromiseFulfilledResult = exports.assertIsPrimitive = exports.assertIsPositiveInteger = exports.assertIsNumberGTEOne = exports.assertIsPositiveFiniteNumber = exports.assertIsOptionalSymbol = exports.assertIsOptionalString = exports.assertIsOptionalNumber = exports.assertIsOptionalNull = exports.assertIsOptionalBoolean = exports.assertIsOptionalBigInt = exports.assertIsObject = exports.assertIsNumericValueArray = exports.assertIsNumericValue = exports.assertIsNumericString = exports.assertIsNumber = exports.assertIsNull = exports.assertIsLengthAware = exports.assertIsIntString = exports.assertIsInteger = exports.assertIsFiniteNumber = exports.assertIsBoolean = exports.assertIsBigInt = void 0;
4
4
  const type_predicate_js_1 = require("./type-predicate.js");
5
- function assertIsInteger(input) {
6
- if (!Number.isInteger(input)) {
7
- throw new TypeError('input is not an integer');
5
+ function getError(error) {
6
+ return error instanceof Error ? error : new TypeError(error);
7
+ }
8
+ function assertIsBigInt(input, error = 'input is not a bigint') {
9
+ if (!(0, type_predicate_js_1.isBigInt)(input)) {
10
+ throw getError(error);
8
11
  }
9
12
  }
10
- exports.assertIsInteger = assertIsInteger;
11
- function assertIsFiniteNumber(input) {
12
- if (!Number.isFinite(input)) {
13
- throw new TypeError('input is not a finite number');
13
+ exports.assertIsBigInt = assertIsBigInt;
14
+ function assertIsBoolean(input, error = 'input is not a boolean') {
15
+ if (!(0, type_predicate_js_1.isBoolean)(input)) {
16
+ throw getError(error);
17
+ }
18
+ }
19
+ exports.assertIsBoolean = assertIsBoolean;
20
+ function assertIsFiniteNumber(input, error = 'input is not a finite number') {
21
+ if (!(0, type_predicate_js_1.isFiniteNumber)(input)) {
22
+ throw getError(error);
14
23
  }
15
24
  }
16
25
  exports.assertIsFiniteNumber = assertIsFiniteNumber;
17
- function assertIsNumericValueArray(input) {
26
+ function assertIsInteger(input, error = 'input is not an integer') {
27
+ if (!(0, type_predicate_js_1.isInteger)(input)) {
28
+ throw getError(error);
29
+ }
30
+ }
31
+ exports.assertIsInteger = assertIsInteger;
32
+ function assertIsIntString(input, error = 'input is not an integer string') {
33
+ if (!(0, type_predicate_js_1.isIntString)(input)) {
34
+ throw getError(error);
35
+ }
36
+ }
37
+ exports.assertIsIntString = assertIsIntString;
38
+ function assertIsLengthAware(input, error = 'input is not length aware') {
39
+ if (!(0, type_predicate_js_1.isLengthAware)(input)) {
40
+ throw getError(error);
41
+ }
42
+ }
43
+ exports.assertIsLengthAware = assertIsLengthAware;
44
+ function assertIsNull(input, error = 'input is not null') {
45
+ if (!(0, type_predicate_js_1.isNull)(input)) {
46
+ throw getError(error);
47
+ }
48
+ }
49
+ exports.assertIsNull = assertIsNull;
50
+ function assertIsNumber(input, error = 'input is not a number') {
51
+ if (!(0, type_predicate_js_1.isNumber)(input)) {
52
+ throw getError(error);
53
+ }
54
+ }
55
+ exports.assertIsNumber = assertIsNumber;
56
+ function assertIsNumericString(input, error = 'input is not a numeric string') {
57
+ if (!(0, type_predicate_js_1.isNumericString)(input)) {
58
+ throw getError(error);
59
+ }
60
+ }
61
+ exports.assertIsNumericString = assertIsNumericString;
62
+ function assertIsNumericValue(input, error = 'input is not a numerical value') {
63
+ if (!(0, type_predicate_js_1.isNumericValue)(input)) {
64
+ throw getError(error);
65
+ }
66
+ }
67
+ exports.assertIsNumericValue = assertIsNumericValue;
68
+ function assertIsNumericValueArray(input, error = 'input is not a numerical value array') {
18
69
  if (!(0, type_predicate_js_1.isNumericValueArray)(input)) {
19
- throw new TypeError('all items must be a NumericValue');
70
+ throw getError(error);
20
71
  }
21
72
  }
22
73
  exports.assertIsNumericValueArray = assertIsNumericValueArray;
74
+ function assertIsObject(input, error = 'input is not an object') {
75
+ if (!(0, type_predicate_js_1.isObject)(input)) {
76
+ throw getError(error);
77
+ }
78
+ }
79
+ exports.assertIsObject = assertIsObject;
80
+ function assertIsOptionalBigInt(input, error = 'input is not an optional bigint') {
81
+ if (!(0, type_predicate_js_1.isOptionalBigInt)(input)) {
82
+ throw getError(error);
83
+ }
84
+ }
85
+ exports.assertIsOptionalBigInt = assertIsOptionalBigInt;
86
+ function assertIsOptionalBoolean(input, error = 'input is not an optional boolean') {
87
+ if (!(0, type_predicate_js_1.isOptionalBoolean)(input)) {
88
+ throw getError(error);
89
+ }
90
+ }
91
+ exports.assertIsOptionalBoolean = assertIsOptionalBoolean;
92
+ function assertIsOptionalNull(input, error = 'input is not an optional null') {
93
+ if (!(0, type_predicate_js_1.isOptionalNull)(input)) {
94
+ throw getError(error);
95
+ }
96
+ }
97
+ exports.assertIsOptionalNull = assertIsOptionalNull;
98
+ function assertIsOptionalNumber(input, error = 'input is not an optional number') {
99
+ if (!(0, type_predicate_js_1.isOptionalNumber)(input)) {
100
+ throw getError(error);
101
+ }
102
+ }
103
+ exports.assertIsOptionalNumber = assertIsOptionalNumber;
104
+ function assertIsOptionalString(input, error = 'input is not an optional string') {
105
+ if (!(0, type_predicate_js_1.isOptionalString)(input)) {
106
+ throw getError(error);
107
+ }
108
+ }
109
+ exports.assertIsOptionalString = assertIsOptionalString;
110
+ function assertIsOptionalSymbol(input, error = 'input is not an optional symbol') {
111
+ if (!(0, type_predicate_js_1.isOptionalSymbol)(input)) {
112
+ throw getError(error);
113
+ }
114
+ }
115
+ exports.assertIsOptionalSymbol = assertIsOptionalSymbol;
116
+ function assertIsPositiveFiniteNumber(input, error = 'input is not a positive finite number') {
117
+ if (!(0, type_predicate_js_1.isPositiveFiniteNumber)(input)) {
118
+ throw getError(error);
119
+ }
120
+ }
121
+ exports.assertIsPositiveFiniteNumber = assertIsPositiveFiniteNumber;
122
+ function assertIsNumberGTEOne(input, error = 'input is not a number >= 1') {
123
+ if (!(0, type_predicate_js_1.isPositiveFiniteNumber)(input) || input < 1) {
124
+ throw getError(error);
125
+ }
126
+ }
127
+ exports.assertIsNumberGTEOne = assertIsNumberGTEOne;
128
+ function assertIsPositiveInteger(input, error = 'input is not a positive integer') {
129
+ if (!(0, type_predicate_js_1.isPositiveInteger)(input)) {
130
+ throw getError(error);
131
+ }
132
+ }
133
+ exports.assertIsPositiveInteger = assertIsPositiveInteger;
134
+ function assertIsPrimitive(input, error = 'input is not primitive') {
135
+ if (!(0, type_predicate_js_1.isPrimitive)(input)) {
136
+ throw getError(error);
137
+ }
138
+ }
139
+ exports.assertIsPrimitive = assertIsPrimitive;
140
+ function assertIsPromiseFulfilledResult(input, error = 'input is not a promise fulfilled result') {
141
+ if (!(0, type_predicate_js_1.isPromiseFulfilledResult)(input)) {
142
+ throw getError(error);
143
+ }
144
+ }
145
+ exports.assertIsPromiseFulfilledResult = assertIsPromiseFulfilledResult;
146
+ function assertIsPromiseRejectedResult(input, error = 'input is not a promise rejected result') {
147
+ if (!(0, type_predicate_js_1.isPromiseRejectedResult)(input)) {
148
+ throw getError(error);
149
+ }
150
+ }
151
+ exports.assertIsPromiseRejectedResult = assertIsPromiseRejectedResult;
152
+ function assertIsPropertyKey(input, error = 'input is not a property key') {
153
+ if (!(0, type_predicate_js_1.isPropertyKey)(input)) {
154
+ throw getError(error);
155
+ }
156
+ }
157
+ exports.assertIsPropertyKey = assertIsPropertyKey;
158
+ function assertIsString(input, error = 'input is not a string') {
159
+ if (!(0, type_predicate_js_1.isString)(input)) {
160
+ throw getError(error);
161
+ }
162
+ }
163
+ exports.assertIsString = assertIsString;
164
+ function assertIsStringMatching(input, pattern, error = 'input is not a string that matches the pattern') {
165
+ if (!(0, type_predicate_js_1.isStringMatching)(input, pattern)) {
166
+ throw getError(error);
167
+ }
168
+ }
169
+ exports.assertIsStringMatching = assertIsStringMatching;
170
+ function assertIsStringRecord(input, error = 'input is not a string record') {
171
+ if (!(0, type_predicate_js_1.isStringRecord)(input)) {
172
+ throw getError(error);
173
+ }
174
+ }
175
+ exports.assertIsStringRecord = assertIsStringRecord;
176
+ function assertIsStringWithLength(input, error = 'input is not a string with length') {
177
+ if (!(0, type_predicate_js_1.isStringWithLength)(input)) {
178
+ throw getError(error);
179
+ }
180
+ }
181
+ exports.assertIsStringWithLength = assertIsStringWithLength;
182
+ function assertIsSymbol(input, error = 'input is not a symbol') {
183
+ if (!(0, type_predicate_js_1.isSymbol)(input)) {
184
+ throw getError(error);
185
+ }
186
+ }
187
+ exports.assertIsSymbol = assertIsSymbol;
188
+ function assertIsUndefined(input, error = 'input is not undefined') {
189
+ if (!(0, type_predicate_js_1.isUndefined)(input)) {
190
+ throw getError(error);
191
+ }
192
+ }
193
+ exports.assertIsUndefined = assertIsUndefined;
194
+ function assertExhaustive(_, error = 'Failed exhaustive check') {
195
+ throw getError(error);
196
+ }
197
+ exports.assertExhaustive = assertExhaustive;
23
198
  //# sourceMappingURL=type-assertion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-assertion.js","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":";;;AAAA,2DAA0D;AAG1D,SAAgB,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;QAC5B,MAAM,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;KAChD;AACH,CAAC;AAJD,0CAIC;AAED,SAAgB,oBAAoB,CAAC,KAAc;IACjD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3B,MAAM,IAAI,SAAS,CAAC,8BAA8B,CAAC,CAAC;KACrD;AACH,CAAC;AAJD,oDAIC;AAED,SAAgB,yBAAyB,CAAC,KAAc;IACtD,IAAI,CAAC,IAAA,uCAAmB,EAAC,KAAK,CAAC,EAAE;QAC/B,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;KACzD;AACH,CAAC;AAJD,8DAIC"}
1
+ {"version":3,"file":"type-assertion.js","sourceRoot":"","sources":["../../src/type-assertion.ts"],"names":[],"mappings":";;;AAAA,2DA+B6B;AAI7B,SAAS,QAAQ,CAAC,KAAqB;IACrC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC,KAAK,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AC,KAAK,EAAE,OAAO,CAAC,EAAE;QACrC,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;KACvB;AACH,CAAC;AARD,wDAQC;AAED,SAAgB,oBAAoB,CAClC,KAAc,EACd,QAAwB,8BAA8B;IAEtD,IAAI,CAAC,IAAA,kCAAc,EAAC,KAAK,CAAC,EAAE;QAC1B,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;KACvB;AACH,CAAC;AAPD,oDAOC;AAED,SAAgB,wBAAwB,CACtC,KAAc,EACd,QAAwB,mCAAmC;IAE3D,IAAI,CAAC,IAAA,sCAAkB,EAAC,KAAK,CAAC,EAAE;QAC9B,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;KACvB;AACH,CAAC;AAPD,4DAOC;AAED,SAAgB,cAAc,CAC5B,KAAc,EACd,QAAwB,uBAAuB;IAE/C,IAAI,CAAC,IAAA,4BAAQ,EAAC,KAAK,CAAC,EAAE;QACpB,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;KACvB;AACH,CAAC;AAPD,wCAOC;AAED,SAAgB,iBAAiB,CAC/B,KAAc,EACd,QAAwB,wBAAwB;IAEhD,IAAI,CAAC,IAAA,+BAAW,EAAC,KAAK,CAAC,EAAE;QACvB,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;KACvB;AACH,CAAC;AAPD,8CAOC;AAED,SAAgB,gBAAgB,CAAC,CAAQ,EAAE,QAAwB,yBAAyB;IAC1F,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAFD,4CAEC"}
@@ -1,14 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isObject = exports.isPrimitive = exports.isLengthAware = exports.isPositiveFiniteNumber = exports.isPositiveInteger = exports.isInteger = exports.isFiniteNumber = exports.isIntString = exports.isNumericValueArray = exports.isNumericValue = exports.isNumericString = exports.isPropertyKey = exports.isStringMatching = exports.isOptionalNumber = exports.isOptionalString = void 0;
4
- const isOptionalString = (input) => typeof input === 'string' || typeof input === 'undefined';
3
+ exports.isPromiseRejectedResult = exports.isPromiseFulfilledResult = exports.isStringRecord = exports.isLengthAware = exports.isObject = exports.isPropertyKey = exports.isPositiveFiniteNumber = exports.isPositiveInteger = exports.isInteger = exports.isFiniteNumber = exports.isIntString = exports.isNumericValueArray = exports.isNumericValue = exports.isNumericString = exports.isStringMatching = exports.isStringWithLength = exports.isOptionalNull = exports.isOptionalSymbol = exports.isOptionalBoolean = exports.isOptionalBigInt = exports.isOptionalNumber = exports.isOptionalString = exports.isPrimitive = exports.isNull = exports.isSymbol = exports.isUndefined = exports.isBoolean = exports.isBigInt = exports.isNumber = exports.isString = exports.maybeUndefined = exports.createIsEnumPredicate = void 0;
4
+ const createIsEnumPredicate = (enumObject) => {
5
+ const values = Object.values(enumObject);
6
+ return (input) => {
7
+ return values.includes(input);
8
+ };
9
+ };
10
+ exports.createIsEnumPredicate = createIsEnumPredicate;
11
+ const maybeUndefined = (predicate, input) => {
12
+ return typeof input === 'undefined' || predicate(input);
13
+ };
14
+ exports.maybeUndefined = maybeUndefined;
15
+ // Primitives
16
+ const isString = (input) => typeof input === 'string';
17
+ exports.isString = isString;
18
+ const isNumber = (input) => typeof input === 'number' && !Number.isNaN(input);
19
+ exports.isNumber = isNumber;
20
+ const isBigInt = (input) => typeof input === 'bigint';
21
+ exports.isBigInt = isBigInt;
22
+ const isBoolean = (input) => typeof input === 'boolean';
23
+ exports.isBoolean = isBoolean;
24
+ const isUndefined = (input) => typeof input === 'undefined';
25
+ exports.isUndefined = isUndefined;
26
+ const isSymbol = (input) => typeof input === 'symbol';
27
+ exports.isSymbol = isSymbol;
28
+ const isNull = (input) => input === null;
29
+ exports.isNull = isNull;
30
+ const isPrimitive = (input) => (0, exports.isString)(input) ||
31
+ (0, exports.isNumber)(input) ||
32
+ (0, exports.isBigInt)(input) ||
33
+ (0, exports.isBoolean)(input) ||
34
+ (0, exports.isUndefined)(input) ||
35
+ (0, exports.isSymbol)(input) ||
36
+ (0, exports.isNull)(input);
37
+ exports.isPrimitive = isPrimitive;
38
+ // Optional primitives
39
+ const isOptionalString = (input) => (0, exports.maybeUndefined)(exports.isString, input);
5
40
  exports.isOptionalString = isOptionalString;
6
- const isOptionalNumber = (input) => (typeof input === 'number' && !Number.isNaN(input)) || typeof input === 'undefined';
41
+ const isOptionalNumber = (input) => (0, exports.maybeUndefined)(exports.isNumber, input);
7
42
  exports.isOptionalNumber = isOptionalNumber;
43
+ const isOptionalBigInt = (input) => (0, exports.maybeUndefined)(exports.isBigInt, input);
44
+ exports.isOptionalBigInt = isOptionalBigInt;
45
+ const isOptionalBoolean = (input) => (0, exports.maybeUndefined)(exports.isBoolean, input);
46
+ exports.isOptionalBoolean = isOptionalBoolean;
47
+ const isOptionalSymbol = (input) => (0, exports.maybeUndefined)(exports.isSymbol, input);
48
+ exports.isOptionalSymbol = isOptionalSymbol;
49
+ const isOptionalNull = (input) => (0, exports.maybeUndefined)(exports.isNull, input);
50
+ exports.isOptionalNull = isOptionalNull;
51
+ // Primitives with extra checks
52
+ const isStringWithLength = (input) => typeof input === 'string' && input.length > 0;
53
+ exports.isStringWithLength = isStringWithLength;
8
54
  const isStringMatching = (input, pattern) => typeof input === 'string' && pattern.test(input);
9
55
  exports.isStringMatching = isStringMatching;
10
- const isPropertyKey = (input) => typeof input === 'string' || typeof input === 'number' || typeof input === 'symbol';
11
- exports.isPropertyKey = isPropertyKey;
12
56
  const isNumericString = (input) => (0, exports.isStringMatching)(input, /^[-+]?\d+(\.\d+)?$/);
13
57
  exports.isNumericString = isNumericString;
14
58
  const isNumericValue = (input) => typeof input === 'number' || typeof input === 'bigint' || (0, exports.isNumericString)(input);
@@ -17,7 +61,7 @@ const isNumericValueArray = (input) => Array.isArray(input) && input.every(expor
17
61
  exports.isNumericValueArray = isNumericValueArray;
18
62
  const isIntString = (input) => (0, exports.isStringMatching)(input, /^[-+]?\d+$/);
19
63
  exports.isIntString = isIntString;
20
- const isFiniteNumber = (input) => typeof input === 'number' && Number.isFinite(input);
64
+ const isFiniteNumber = (input) => Number.isFinite(input);
21
65
  exports.isFiniteNumber = isFiniteNumber;
22
66
  const isInteger = (input) => Number.isInteger(input);
23
67
  exports.isInteger = isInteger;
@@ -25,18 +69,23 @@ const isPositiveInteger = (input) => (0, exports.isInteger)(input) && input >= 0
25
69
  exports.isPositiveInteger = isPositiveInteger;
26
70
  const isPositiveFiniteNumber = (input) => (0, exports.isFiniteNumber)(input) && input >= 0;
27
71
  exports.isPositiveFiniteNumber = isPositiveFiniteNumber;
28
- const isLengthAware = (input) =>
29
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
- typeof input === 'object' && input !== null && 'length' in input && typeof input.length === 'number';
31
- exports.isLengthAware = isLengthAware;
32
- const isPrimitive = (input) => typeof input === 'string' ||
33
- typeof input === 'number' ||
34
- typeof input === 'bigint' ||
35
- typeof input === 'boolean' ||
36
- typeof input === 'undefined' ||
37
- typeof input === 'symbol' ||
38
- input === null;
39
- exports.isPrimitive = isPrimitive;
72
+ // Common types
73
+ const isPropertyKey = (input) => typeof input === 'string' || typeof input === 'number' || typeof input === 'symbol';
74
+ exports.isPropertyKey = isPropertyKey;
40
75
  const isObject = (input) => input !== null && typeof input === 'object' && !Array.isArray(input);
41
76
  exports.isObject = isObject;
77
+ const isLengthAware = (input) => input !== null && typeof input === 'object' && 'length' in input && typeof input.length === 'number';
78
+ exports.isLengthAware = isLengthAware;
79
+ const isStringRecord = (input) => {
80
+ return (0, exports.isObject)(input) && Object.entries(input).every(entry => entry.every(exports.isString));
81
+ };
82
+ exports.isStringRecord = isStringRecord;
83
+ const isPromiseFulfilledResult = (input) => {
84
+ return (0, exports.isObject)(input) && input.status === 'fulfilled';
85
+ };
86
+ exports.isPromiseFulfilledResult = isPromiseFulfilledResult;
87
+ const isPromiseRejectedResult = (input) => {
88
+ return (0, exports.isObject)(input) && input.status === 'rejected' && 'reason' in input;
89
+ };
90
+ exports.isPromiseRejectedResult = isPromiseRejectedResult;
42
91
  //# sourceMappingURL=type-predicate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-predicate.js","sourceRoot":"","sources":["../../src/type-predicate.ts"],"names":[],"mappings":";;;AAEO,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA+B,EAAE,CAC9E,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;AAD/C,QAAA,gBAAgB,oBAC+B;AAErD,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAA+B,EAAE,CAC9E,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC;AADzE,QAAA,gBAAgB,oBACyD;AAE/E,MAAM,gBAAgB,GAAG,CAAC,KAAc,EAAE,OAAe,EAAmB,EAAE,CACnF,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AADtC,QAAA,gBAAgB,oBACsB;AAE5C,MAAM,aAAa,GAAG,CAAC,KAAc,EAAwB,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AADzE,QAAA,aAAa,iBAC4D;AAE/E,MAAM,eAAe,GAAG,CAAC,KAAc,EAA0B,EAAE,CACxE,IAAA,wBAAgB,EAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;AADnC,QAAA,eAAe,mBACoB;AAEzC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CACtE,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;AADtE,QAAA,cAAc,kBACwD;AAE5E,MAAM,mBAAmB,GAAG,CAAC,KAAc,EAA2B,EAAE,CAC7E,KAAK,CAAC,OA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K,QAAQ,CAAC;AAD1F,QAAA,aAAa,iBAC6E;AAEhG,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE;IACtE,OAAO,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAQ,CAAC,CAAC,CAAC;AACxF,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB;AAEK,MAAM,wBAAwB,GAAG,CAAI,KAAc,EAAsC,EAAE;IAChG,OAAO,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC;AACzD,CAAC,CAAC;AAFW,QAAA,wBAAwB,4BAEnC;AAEK,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAkC,EAAE;IACxF,OAAO,IAAA,gBAAQ,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,UAAU,IAAI,QAAQ,IAAI,KAAK,CAAC;AAC7E,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC"}
@@ -0,0 +1,2 @@
1
+ export const capitalize = (word) => word.substring(0, 1).toUpperCase() + word.substring(1);
2
+ //# sourceMappingURL=capitalize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capitalize.js","sourceRoot":"","sources":["../../src/capitalize.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC"}
package/dist/mjs/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './asArray.js';
2
+ export * from './capitalize.js';
2
3
  export * from './clamp.js';
3
4
  export * from './compose.js';
4
5
  export * from './convert.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,sBA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,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;oBAC/D,MAAM,WAAW,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAC;oBAC5C,yFAAyF;oBACzF,MAAM,KAAK,GACT,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,WAAW,IAAI,QAAQ,CAAC,WAAW,CAAC;wBACvD,CAAC,CAAE,EAAoD;wBACvD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAEhB,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;oBAErC,OAAO,IAAI,CAAC;gBACd,CAAC,EAAE,aAAa,CAAC,CAAC;aACnB;SACF;QAED,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IAEF,OAAO,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACpC,CAAC"}
@@ -1,30 +1,19 @@
1
+ import { capitalize } from './capitalize.js';
1
2
  import { getType } from './getType.js';
2
3
  export function toPascalCase(text, customWords) {
3
- let words = String(text).match(/[A-Z][a-z']+|\d+|[a-z']+/g);
4
- if (!words) {
4
+ const words = String(text).match(/[A-Z][a-z']+|\d+|[a-z']+/g);
5
+ if (words === null) {
5
6
  return '';
6
7
  }
7
- // Remove apostrophes then uppercase the first letter of each word.
8
- words = words.map(word => {
9
- const fixedWord = word.replace(/'/g, '');
10
- return fixedWord.substring(0, 1).toUpperCase() + fixedWord.substring(1);
11
- });
8
+ let fixedWords = words.map(word => capitalize(word.replace(/'/g, '')));
12
9
  if (customWords && getType(customWords) === 'Object') {
13
- const replacements = Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]);
14
- if (replacements.length) {
10
+ const replacements = new Map(Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]));
11
+ if (replacements.size) {
15
12
  // This takes a single word and returns the first matching replacement, if any.
16
- const replaceCustomWords = (word) => {
17
- const lowerWord = word.toLowerCase();
18
- for (const [key, value] of replacements) {
19
- if (key === lowerWord && typeof value === 'string') {
20
- return value;
21
- }
22
- }
23
- return word;
24
- };
25
- words = words.map(replaceCustomWords);
13
+ const replaceCustomWords = (word) => replacements.get(word.toLowerCase()) ?? word;
14
+ fixedWords = fixedWords.map(replaceCustomWords);
26
15
  }
27
16
  }
28
- return words.join('');
17
+ return fixedWords.join('');
29
18
  }
30
19
  //# sourceMappingURL=toPascalCase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toPascalCase.js","sourceRoot":"","sources":["../../src/toPascalCase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,WAAoC;IAC7E,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAE5D,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IAED,mEAAmE;IACnE,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAEzC,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;IAEH,IAAI,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,KAAK,QAAQ,EAAE;QACpD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnG,IAAI,YAAY,CAAC,MAAM,EAAE;YACvB,+EAA+E;YAC/E,MAAM,kBAAkB,G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