inferred-types 0.49.10 → 0.50.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 (46) hide show
  1. package/dist/constants/Characters.d.ts +1 -1
  2. package/dist/constants/Characters.d.ts.map +1 -1
  3. package/dist/constants/Characters.js +2 -1
  4. package/dist/constants/tsconfig.tsbuildinfo +1 -1
  5. package/dist/inferred-types/index.cjs +38 -8
  6. package/dist/inferred-types/tsconfig.tsbuildinfo +1 -1
  7. package/dist/runtime/literals/index.d.ts +1 -0
  8. package/dist/runtime/literals/index.d.ts.map +1 -1
  9. package/dist/runtime/literals/index.js +1 -0
  10. package/dist/runtime/literals/pluralize.d.ts.map +1 -1
  11. package/dist/runtime/literals/pluralize.js +15 -13
  12. package/dist/runtime/literals/retainAfter.d.ts +19 -2
  13. package/dist/runtime/literals/retainAfter.d.ts.map +1 -1
  14. package/dist/runtime/literals/retainAfter.js +35 -5
  15. package/dist/runtime/literals/rightWhitespace.d.ts +9 -0
  16. package/dist/runtime/literals/rightWhitespace.d.ts.map +1 -0
  17. package/dist/runtime/literals/rightWhitespace.js +11 -0
  18. package/dist/runtime/tsconfig.tsbuildinfo +1 -1
  19. package/dist/types/boolean-logic/combinators/Compare.d.ts +10 -3
  20. package/dist/types/boolean-logic/combinators/Compare.d.ts.map +1 -1
  21. package/dist/types/lists/AsNumericArray.d.ts +16 -0
  22. package/dist/types/lists/AsNumericArray.d.ts.map +1 -0
  23. package/dist/types/lists/AsNumericArray.js +1 -0
  24. package/dist/types/lists/FilterByProp.d.ts +3 -17
  25. package/dist/types/lists/FilterByProp.d.ts.map +1 -1
  26. package/dist/types/lists/MaxLength.d.ts +17 -0
  27. package/dist/types/lists/MaxLength.d.ts.map +1 -0
  28. package/dist/types/lists/MaxLength.js +1 -0
  29. package/dist/types/lists/NumericSort.d.ts +65 -0
  30. package/dist/types/lists/NumericSort.d.ts.map +1 -0
  31. package/dist/types/lists/NumericSort.js +1 -0
  32. package/dist/types/lists/index.d.ts +3 -0
  33. package/dist/types/lists/index.d.ts.map +1 -1
  34. package/dist/types/lists/index.js +3 -0
  35. package/dist/types/string-literals/FindIndex.d.ts +68 -0
  36. package/dist/types/string-literals/FindIndex.d.ts.map +1 -0
  37. package/dist/types/string-literals/FindIndex.js +1 -0
  38. package/dist/types/string-literals/Pluralize.d.ts +6 -2
  39. package/dist/types/string-literals/Pluralize.d.ts.map +1 -1
  40. package/dist/types/string-literals/RetainAfter.d.ts +20 -8
  41. package/dist/types/string-literals/RetainAfter.d.ts.map +1 -1
  42. package/dist/types/string-literals/index.d.ts +1 -0
  43. package/dist/types/string-literals/index.d.ts.map +1 -1
  44. package/dist/types/string-literals/index.js +1 -0
  45. package/dist/types/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +1 -1
@@ -37,6 +37,7 @@ export * from "./takeNumericCharacters";
37
37
  export * from "./retainChars";
38
38
  export * from "./stripChars";
39
39
  export * from "./retainWhile";
40
+ export * from "./rightWhitespace";
40
41
  export * from "./phone/index";
41
42
  export * from "./color/index";
42
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/index.ts"],"names":[],"mappings":"AAMA,cAAc,OAAO,CAAC;AACtB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,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9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -42,6 +42,7 @@ export * from "./takeNumericCharacters.js";
42
42
  export * from "./retainChars.js";
43
43
  export * from "./stripChars.js";
44
44
  export * from "./retainWhile.js";
45
+ export * from "./rightWhitespace.js";
45
46
  export * from "./phone/index.js";
46
47
  export * from "./color/index.js";
47
48
  // #endregion auto-indexed files
@@ -1 +1 @@
1
- {"version":3,"file":"pluralize.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/pluralize.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,0BAAwB;AA+C5C;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,SAAS,CAAC,CAAC,CAUhE,CAAC"}
1
+ {"version":3,"file":"pluralize.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/pluralize.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,0BAAwB;AA+C5C;;;;;;;;GAQG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,SAAS,CAAC,CAAC,CAYhE,CAAC"}
@@ -1,5 +1,5 @@
1
- import { ALPHA_CHARS, CONSONANTS, PLURAL_EXCEPTIONS, SINGULAR_NOUN_ENDINGS } from "../../constants/index.js";
2
- import { stripTrailing, split } from "../index.js";
1
+ import { ALPHA_CHARS, PLURAL_EXCEPTIONS, SINGULAR_NOUN_ENDINGS } from "../../constants/index.js";
2
+ import { stripTrailing, split, rightWhitespace } from "../index.js";
3
3
  const isException = (word) => Object.keys(PLURAL_EXCEPTIONS).includes(word);
4
4
  const _END_IN = [
5
5
  "is",
@@ -28,9 +28,9 @@ const endingIn = (word, postfix) => {
28
28
  : undefined;
29
29
  case "y":
30
30
  return word.endsWith("y")
31
- ? CONSONANTS.includes(word.slice(-2, 1))
32
- ? stripTrailing(word, "y") + "ies"
33
- : undefined
31
+ // ? CONSONANTS.includes(word.slice(-2, 1) as any)
32
+ ? stripTrailing(word, "y") + "ies"
33
+ // : undefined
34
34
  : undefined;
35
35
  default:
36
36
  throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
@@ -46,12 +46,14 @@ const endingIn = (word, postfix) => {
46
46
  * will be pluralized along with the runtime value._
47
47
  */
48
48
  export const pluralize = (word) => {
49
- const result = isException(word)
50
- ? PLURAL_EXCEPTIONS[word]
51
- : endingIn(word, "is") ||
52
- endingIn(word, "singular-noun") ||
53
- endingIn(word, "f") ||
54
- endingIn(word, "y") ||
55
- `${word}s`; // add "s" if no other patterns match
56
- return result;
49
+ const right = rightWhitespace(word);
50
+ const w = word.trimEnd();
51
+ const result = isException(w)
52
+ ? PLURAL_EXCEPTIONS[w]
53
+ : endingIn(w, "is") ||
54
+ endingIn(w, "singular-noun") ||
55
+ endingIn(w, "f") ||
56
+ endingIn(w, "y") ||
57
+ `${w}s`; // add "s" if no other patterns match
58
+ return `${result}${right}`;
57
59
  };
@@ -1,6 +1,6 @@
1
1
  import { RetainAfter } from "../../types/index";
2
2
  /**
3
- * **retainAfter**(content, find)
3
+ * **retainAfter**`(content, ...find)`
4
4
  *
5
5
  * Runtime utility which removes all characters in a given string _until_
6
6
  * it finds the first instance of a substring defined in **find** variable.
@@ -10,6 +10,23 @@ import { RetainAfter } from "../../types/index";
10
10
  * // "world"
11
11
  * const world = retainAfter("hello world", " ");
12
12
  * ```
13
+ *
14
+ * **Related:** `retainAfterInclusive()`
15
+ */
16
+ export declare function retainAfter<TContent extends string, TFind extends readonly string[]>(content: TContent, ...find: TFind): RetainAfter<TContent, TFind[number]>;
17
+ /**
18
+ * **retainAfterInclusive**`(content, ...find)`
19
+ *
20
+ * Runtime utility which removes all characters in a given string _until_
21
+ * it finds the first instance of a substring defined in **find** variable.
22
+ *
23
+ * ### Example
24
+ * ```ts
25
+ * // " world"
26
+ * const world = retainAfter("hello world", " ");
27
+ * ```
28
+ *
29
+ * **Related:** `retainAfter()`
13
30
  */
14
- export declare function retainAfter<TContent extends string, TBreak extends string>(content: TContent, find: TBreak): RetainAfter<TContent, TBreak>;
31
+ export declare function retainAfterInclusive<TContent extends string, TFind extends readonly string[]>(content: TContent, ...find: TFind): RetainAfter<TContent, TFind[number], true>;
15
32
  //# sourceMappingURL=retainAfter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"retainAfter.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/retainAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0BAAwB;AAE9C;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,QAAQ,SAAS,MAAM,EACvB,MAAM,SAAS,MAAM,EACrB,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAGO,WAAW,CAAC,QAAQ,EAAC,MAAM,CAAC,CACnE"}
1
+ {"version":3,"file":"retainAfter.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/retainAfter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,0BAAwB;AAE9C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CACzB,QAAQ,SAAS,MAAM,EACvB,KAAK,SAAS,SAAS,MAAM,EAAE,EAC/B,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,KAAK,GAiB5B,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAC1C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CACpC,QAAQ,SAAS,MAAM,EACvB,KAAK,SAAS,SAAS,MAAM,EAAE,EAE7B,OAAO,EAAE,QAAQ,EACjB,GAAG,IAAI,EAAE,KAAK,GAWX,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAC9C"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * **retainAfter**(content, find)
2
+ * **retainAfter**`(content, ...find)`
3
3
  *
4
4
  * Runtime utility which removes all characters in a given string _until_
5
5
  * it finds the first instance of a substring defined in **find** variable.
@@ -9,9 +9,39 @@
9
9
  * // "world"
10
10
  * const world = retainAfter("hello world", " ");
11
11
  * ```
12
+ *
13
+ * **Related:** `retainAfterInclusive()`
14
+ */
15
+ export function retainAfter(content, ...find) {
16
+ const idx = Math.min(...find.map(i => content.indexOf(i)).filter(i => i > -1));
17
+ const min = Math.min(...find.map(i => i.length));
18
+ let len = Math.max(...find.map(i => i.length));
19
+ if (min !== len) {
20
+ if (!find.includes(content.slice(idx, len))) {
21
+ len = min;
22
+ }
23
+ }
24
+ return (idx && idx > 0
25
+ ? content.slice(idx + len)
26
+ : "");
27
+ }
28
+ /**
29
+ * **retainAfterInclusive**`(content, ...find)`
30
+ *
31
+ * Runtime utility which removes all characters in a given string _until_
32
+ * it finds the first instance of a substring defined in **find** variable.
33
+ *
34
+ * ### Example
35
+ * ```ts
36
+ * // " world"
37
+ * const world = retainAfter("hello world", " ");
38
+ * ```
39
+ *
40
+ * **Related:** `retainAfter()`
12
41
  */
13
- export function retainAfter(content, find) {
14
- const parts = content.split(find);
15
- parts.shift();
16
- return parts.join(find);
42
+ export function retainAfterInclusive(content, ...find) {
43
+ const minFound = Math.min(...find.map(i => content.indexOf(i)).filter(i => i > -1));
44
+ return (minFound > 0
45
+ ? content.slice(minFound)
46
+ : "");
17
47
  }
@@ -0,0 +1,9 @@
1
+ import { TrimLeft } from "../../types/type-conversion";
2
+ import { RetainAfter, Whitespace } from "../../types/string-literals";
3
+ /**
4
+ * **rightWhitespace**`(content)`
5
+ *
6
+ * Extracts and returns the whitespace on the _right_ part of the string.
7
+ */
8
+ export declare const rightWhitespace: <T extends string>(content: T) => RetainAfter<TrimLeft<T>, Whitespace, true>;
9
+ //# sourceMappingURL=rightWhitespace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rightWhitespace.d.ts","sourceRoot":"","sources":["../../../src/runtime/literals/rightWhitespace.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,oCAAiC;AACpD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,oCAAiC;AAEnE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,MAAM,WAAW,CAAC,KAK1C,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAC1D,CAAA"}
@@ -0,0 +1,11 @@
1
+ import { WHITESPACE_CHARS } from "../../constants/Characters.js";
2
+ import { retainAfterInclusive } from "./retainAfter.js";
3
+ /**
4
+ * **rightWhitespace**`(content)`
5
+ *
6
+ * Extracts and returns the whitespace on the _right_ part of the string.
7
+ */
8
+ export const rightWhitespace = (content) => {
9
+ const trimmed = content.trimStart();
10
+ return retainAfterInclusive(trimmed, ...WHITESPACE_CHARS);
11
+ };