@duplojs/utils 1.1.13 → 1.1.15

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 (242) hide show
  1. package/dist/array/flat.cjs +1 -13
  2. package/dist/array/flat.d.ts +1 -4
  3. package/dist/array/flat.mjs +1 -13
  4. package/dist/array/index.cjs +2 -0
  5. package/dist/array/index.d.ts +1 -0
  6. package/dist/array/index.mjs +1 -0
  7. package/dist/array/notIncludes.cjs +12 -0
  8. package/dist/array/notIncludes.d.ts +4 -0
  9. package/dist/array/notIncludes.mjs +10 -0
  10. package/dist/array/reduce.d.ts +6 -7
  11. package/dist/array/reduceRight.d.ts +4 -3
  12. package/dist/common/createKindIdentifier.cjs +27 -0
  13. package/dist/common/createKindIdentifier.d.ts +7 -0
  14. package/dist/common/createKindIdentifier.mjs +25 -0
  15. package/dist/common/index.d.ts +1 -0
  16. package/dist/common/isType.cjs +12 -1
  17. package/dist/common/isType.d.ts +4 -2
  18. package/dist/common/isType.mjs +12 -1
  19. package/dist/common/justReturn.d.ts +2 -2
  20. package/dist/common/kind.d.ts +2 -2
  21. package/dist/common/or.d.ts +9 -9
  22. package/dist/common/types/index.d.ts +1 -0
  23. package/dist/common/types/onlyLiteral.d.ts +18 -0
  24. package/dist/dataParser/base.cjs +55 -29
  25. package/dist/dataParser/base.d.ts +1 -1
  26. package/dist/dataParser/base.mjs +55 -29
  27. package/dist/dataParser/baseExtended.cjs +15 -2
  28. package/dist/dataParser/baseExtended.d.ts +8 -3
  29. package/dist/dataParser/baseExtended.mjs +15 -2
  30. package/dist/dataParser/extended/array.cjs +1 -0
  31. package/dist/dataParser/extended/array.d.ts +11 -5
  32. package/dist/dataParser/extended/array.mjs +1 -0
  33. package/dist/dataParser/extended/bigint.cjs +1 -0
  34. package/dist/dataParser/extended/bigint.d.ts +9 -2
  35. package/dist/dataParser/extended/bigint.mjs +1 -0
  36. package/dist/dataParser/extended/boolean.cjs +1 -0
  37. package/dist/dataParser/extended/boolean.d.ts +13 -2
  38. package/dist/dataParser/extended/boolean.mjs +1 -0
  39. package/dist/dataParser/extended/coerce/bigint.cjs +1 -0
  40. package/dist/dataParser/extended/coerce/bigint.mjs +1 -0
  41. package/dist/dataParser/extended/coerce/boolean.cjs +1 -0
  42. package/dist/dataParser/extended/coerce/boolean.mjs +1 -0
  43. package/dist/dataParser/extended/coerce/empty.cjs +1 -0
  44. package/dist/dataParser/extended/coerce/empty.mjs +1 -0
  45. package/dist/dataParser/extended/coerce/nil.cjs +1 -0
  46. package/dist/dataParser/extended/coerce/nil.mjs +1 -0
  47. package/dist/dataParser/extended/coerce/number.cjs +1 -0
  48. package/dist/dataParser/extended/coerce/number.mjs +1 -0
  49. package/dist/dataParser/extended/coerce/string.cjs +1 -0
  50. package/dist/dataParser/extended/coerce/string.mjs +1 -0
  51. package/dist/dataParser/extended/empty.cjs +1 -0
  52. package/dist/dataParser/extended/empty.d.ts +13 -2
  53. package/dist/dataParser/extended/empty.mjs +1 -0
  54. package/dist/dataParser/extended/index.cjs +2 -0
  55. package/dist/dataParser/extended/index.d.ts +1 -0
  56. package/dist/dataParser/extended/index.mjs +1 -0
  57. package/dist/dataParser/extended/lazy.cjs +1 -0
  58. package/dist/dataParser/extended/lazy.d.ts +13 -3
  59. package/dist/dataParser/extended/lazy.mjs +1 -0
  60. package/dist/dataParser/extended/literal.cjs +1 -0
  61. package/dist/dataParser/extended/literal.d.ts +13 -2
  62. package/dist/dataParser/extended/literal.mjs +1 -0
  63. package/dist/dataParser/extended/nil.cjs +1 -0
  64. package/dist/dataParser/extended/nil.d.ts +13 -2
  65. package/dist/dataParser/extended/nil.mjs +1 -0
  66. package/dist/dataParser/extended/nullable.cjs +1 -0
  67. package/dist/dataParser/extended/nullable.d.ts +14 -4
  68. package/dist/dataParser/extended/nullable.mjs +1 -0
  69. package/dist/dataParser/extended/number.cjs +1 -0
  70. package/dist/dataParser/extended/number.d.ts +9 -2
  71. package/dist/dataParser/extended/number.mjs +1 -0
  72. package/dist/dataParser/extended/object.cjs +1 -0
  73. package/dist/dataParser/extended/object.d.ts +13 -2
  74. package/dist/dataParser/extended/object.mjs +1 -0
  75. package/dist/dataParser/extended/optional.cjs +1 -0
  76. package/dist/dataParser/extended/optional.d.ts +14 -4
  77. package/dist/dataParser/extended/optional.mjs +1 -0
  78. package/dist/dataParser/extended/pipe.cjs +1 -0
  79. package/dist/dataParser/extended/pipe.d.ts +13 -3
  80. package/dist/dataParser/extended/pipe.mjs +1 -0
  81. package/dist/dataParser/extended/record.cjs +3 -2
  82. package/dist/dataParser/extended/record.d.ts +13 -3
  83. package/dist/dataParser/extended/record.mjs +2 -1
  84. package/dist/dataParser/extended/recover.cjs +14 -0
  85. package/dist/dataParser/extended/recover.d.ts +23 -0
  86. package/dist/dataParser/extended/recover.mjs +12 -0
  87. package/dist/dataParser/extended/string.cjs +1 -0
  88. package/dist/dataParser/extended/string.d.ts +9 -2
  89. package/dist/dataParser/extended/string.mjs +1 -0
  90. package/dist/dataParser/extended/templateLiteral.cjs +4 -2
  91. package/dist/dataParser/extended/templateLiteral.d.ts +13 -2
  92. package/dist/dataParser/extended/templateLiteral.mjs +3 -1
  93. package/dist/dataParser/extended/transform.cjs +1 -0
  94. package/dist/dataParser/extended/transform.d.ts +12 -2
  95. package/dist/dataParser/extended/transform.mjs +1 -0
  96. package/dist/dataParser/extended/tuple.cjs +11 -1
  97. package/dist/dataParser/extended/tuple.d.ts +19 -2
  98. package/dist/dataParser/extended/tuple.mjs +11 -1
  99. package/dist/dataParser/extended/union.cjs +1 -0
  100. package/dist/dataParser/extended/union.d.ts +13 -2
  101. package/dist/dataParser/extended/union.mjs +1 -0
  102. package/dist/dataParser/extended/unknown.cjs +1 -0
  103. package/dist/dataParser/extended/unknown.d.ts +13 -2
  104. package/dist/dataParser/extended/unknown.mjs +1 -0
  105. package/dist/dataParser/identifier.cjs +2 -17
  106. package/dist/dataParser/identifier.d.ts +216 -8
  107. package/dist/dataParser/identifier.mjs +2 -17
  108. package/dist/dataParser/index.cjs +29 -18
  109. package/dist/dataParser/index.mjs +18 -14
  110. package/dist/dataParser/parsers/array/checkers/max.cjs +3 -3
  111. package/dist/dataParser/parsers/array/checkers/max.d.ts +2 -2
  112. package/dist/dataParser/parsers/array/checkers/max.mjs +3 -3
  113. package/dist/dataParser/parsers/array/checkers/min.cjs +3 -3
  114. package/dist/dataParser/parsers/array/checkers/min.d.ts +2 -2
  115. package/dist/dataParser/parsers/array/checkers/min.mjs +3 -3
  116. package/dist/dataParser/parsers/array/index.d.ts +14 -7
  117. package/dist/dataParser/parsers/bigint/checkers/max.cjs +3 -3
  118. package/dist/dataParser/parsers/bigint/checkers/max.d.ts +2 -2
  119. package/dist/dataParser/parsers/bigint/checkers/max.mjs +3 -3
  120. package/dist/dataParser/parsers/bigint/checkers/min.cjs +3 -3
  121. package/dist/dataParser/parsers/bigint/checkers/min.d.ts +2 -2
  122. package/dist/dataParser/parsers/bigint/checkers/min.mjs +3 -3
  123. package/dist/dataParser/parsers/bigint/index.d.ts +11 -4
  124. package/dist/dataParser/parsers/boolean.d.ts +16 -4
  125. package/dist/dataParser/parsers/coerce/bigint.cjs +1 -0
  126. package/dist/dataParser/parsers/coerce/bigint.mjs +1 -0
  127. package/dist/dataParser/parsers/coerce/boolean.cjs +1 -0
  128. package/dist/dataParser/parsers/coerce/boolean.mjs +1 -0
  129. package/dist/dataParser/parsers/coerce/empty.cjs +1 -0
  130. package/dist/dataParser/parsers/coerce/empty.mjs +1 -0
  131. package/dist/dataParser/parsers/coerce/nil.cjs +1 -0
  132. package/dist/dataParser/parsers/coerce/nil.mjs +1 -0
  133. package/dist/dataParser/parsers/coerce/number.cjs +1 -0
  134. package/dist/dataParser/parsers/coerce/number.mjs +1 -0
  135. package/dist/dataParser/parsers/coerce/string.cjs +1 -0
  136. package/dist/dataParser/parsers/coerce/string.mjs +1 -0
  137. package/dist/dataParser/parsers/empty.d.ts +16 -4
  138. package/dist/dataParser/parsers/index.d.ts +2 -0
  139. package/dist/dataParser/parsers/lazy.d.ts +16 -4
  140. package/dist/dataParser/parsers/literal.d.ts +16 -4
  141. package/dist/dataParser/parsers/nil.d.ts +16 -4
  142. package/dist/dataParser/parsers/nullable.cjs +3 -2
  143. package/dist/dataParser/parsers/nullable.d.ts +19 -6
  144. package/dist/dataParser/parsers/nullable.mjs +3 -2
  145. package/dist/dataParser/parsers/number/checkers/int.cjs +3 -3
  146. package/dist/dataParser/parsers/number/checkers/int.d.ts +2 -2
  147. package/dist/dataParser/parsers/number/checkers/int.mjs +3 -3
  148. package/dist/dataParser/parsers/number/checkers/max.cjs +3 -3
  149. package/dist/dataParser/parsers/number/checkers/max.d.ts +2 -2
  150. package/dist/dataParser/parsers/number/checkers/max.mjs +3 -3
  151. package/dist/dataParser/parsers/number/checkers/min.cjs +3 -3
  152. package/dist/dataParser/parsers/number/checkers/min.d.ts +2 -2
  153. package/dist/dataParser/parsers/number/checkers/min.mjs +3 -3
  154. package/dist/dataParser/parsers/number/index.d.ts +11 -4
  155. package/dist/dataParser/parsers/object.d.ts +16 -4
  156. package/dist/dataParser/parsers/optional.cjs +3 -2
  157. package/dist/dataParser/parsers/optional.d.ts +19 -6
  158. package/dist/dataParser/parsers/optional.mjs +3 -2
  159. package/dist/dataParser/parsers/pipe.d.ts +16 -4
  160. package/dist/dataParser/parsers/record/findRecordRequiredKey.cjs +50 -0
  161. package/dist/dataParser/parsers/record/findRecordRequiredKey.d.ts +4 -0
  162. package/dist/dataParser/parsers/record/findRecordRequiredKey.mjs +47 -0
  163. package/dist/dataParser/parsers/{record.cjs → record/index.cjs} +21 -3
  164. package/dist/dataParser/parsers/record/index.d.ts +42 -0
  165. package/dist/dataParser/parsers/{record.mjs → record/index.mjs} +21 -4
  166. package/dist/dataParser/parsers/recover.cjs +32 -0
  167. package/dist/dataParser/parsers/recover.d.ts +28 -0
  168. package/dist/dataParser/parsers/recover.mjs +29 -0
  169. package/dist/dataParser/parsers/refine.cjs +18 -0
  170. package/dist/dataParser/parsers/refine.d.ts +17 -0
  171. package/dist/dataParser/parsers/refine.mjs +15 -0
  172. package/dist/dataParser/parsers/string/checkers/email.cjs +3 -3
  173. package/dist/dataParser/parsers/string/checkers/email.d.ts +2 -2
  174. package/dist/dataParser/parsers/string/checkers/email.mjs +3 -3
  175. package/dist/dataParser/parsers/string/checkers/max.cjs +3 -3
  176. package/dist/dataParser/parsers/string/checkers/max.d.ts +2 -2
  177. package/dist/dataParser/parsers/string/checkers/max.mjs +3 -3
  178. package/dist/dataParser/parsers/string/checkers/min.cjs +3 -3
  179. package/dist/dataParser/parsers/string/checkers/min.d.ts +2 -2
  180. package/dist/dataParser/parsers/string/checkers/min.mjs +3 -3
  181. package/dist/dataParser/parsers/string/checkers/regex.cjs +3 -3
  182. package/dist/dataParser/parsers/string/checkers/regex.d.ts +2 -2
  183. package/dist/dataParser/parsers/string/checkers/regex.mjs +3 -3
  184. package/dist/dataParser/parsers/string/checkers/url.cjs +3 -3
  185. package/dist/dataParser/parsers/string/checkers/url.d.ts +2 -2
  186. package/dist/dataParser/parsers/string/checkers/url.mjs +3 -3
  187. package/dist/dataParser/parsers/string/index.d.ts +11 -4
  188. package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.cjs +75 -0
  189. package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.d.ts +2 -0
  190. package/dist/dataParser/parsers/templateLiteral/createTemplateLiteralPattern.mjs +73 -0
  191. package/dist/dataParser/parsers/templateLiteral/index.cjs +31 -0
  192. package/dist/dataParser/parsers/templateLiteral/index.d.ts +66 -0
  193. package/dist/dataParser/parsers/templateLiteral/index.mjs +27 -0
  194. package/dist/dataParser/parsers/transform.d.ts +16 -4
  195. package/dist/dataParser/parsers/tuple.d.ts +14 -4
  196. package/dist/dataParser/parsers/union.d.ts +16 -4
  197. package/dist/dataParser/parsers/unknown.d.ts +16 -4
  198. package/dist/dataParser/types/checkers.d.ts +1 -1
  199. package/dist/dataParser/types/dataParsers.d.ts +2 -2
  200. package/dist/either/bool/falsy.cjs +1 -1
  201. package/dist/either/bool/falsy.d.ts +2 -2
  202. package/dist/either/bool/falsy.mjs +1 -1
  203. package/dist/either/bool/truthy.cjs +2 -2
  204. package/dist/either/bool/truthy.d.ts +2 -2
  205. package/dist/either/bool/truthy.mjs +2 -2
  206. package/dist/either/future/create.cjs +1 -1
  207. package/dist/either/future/create.mjs +1 -1
  208. package/dist/either/left/when.d.ts +2 -2
  209. package/dist/either/nullable/empty.cjs +1 -1
  210. package/dist/either/nullable/empty.d.ts +2 -2
  211. package/dist/either/nullable/empty.mjs +1 -1
  212. package/dist/either/nullable/filled.d.ts +2 -2
  213. package/dist/either/nullish/empty.d.ts +2 -2
  214. package/dist/either/nullish/filled.cjs +2 -2
  215. package/dist/either/nullish/filled.d.ts +2 -2
  216. package/dist/either/nullish/filled.mjs +2 -2
  217. package/dist/either/optional/empty.d.ts +2 -2
  218. package/dist/either/optional/filled.cjs +2 -2
  219. package/dist/either/optional/filled.d.ts +2 -2
  220. package/dist/either/optional/filled.mjs +2 -2
  221. package/dist/either/right/asyncPipe.cjs +1 -1
  222. package/dist/either/right/asyncPipe.mjs +1 -1
  223. package/dist/either/right/pipe.cjs +1 -1
  224. package/dist/either/right/pipe.mjs +1 -1
  225. package/dist/either/right/when.d.ts +2 -2
  226. package/dist/generator/asyncReduce.cjs +1 -1
  227. package/dist/generator/asyncReduce.d.ts +4 -3
  228. package/dist/generator/asyncReduce.mjs +1 -1
  229. package/dist/generator/reduce.d.ts +6 -7
  230. package/dist/index.cjs +2 -0
  231. package/dist/index.mjs +1 -0
  232. package/dist/object/entries.d.ts +2 -1
  233. package/dist/object/values.cjs +8 -1
  234. package/dist/object/values.d.ts +1 -3
  235. package/dist/object/values.mjs +8 -1
  236. package/dist/string/types/index.d.ts +1 -0
  237. package/dist/string/types/templateLiteralContainLargeType.d.ts +5 -0
  238. package/package.json +3 -3
  239. package/dist/dataParser/parsers/record.d.ts +0 -30
  240. package/dist/dataParser/parsers/templateLiteral.cjs +0 -47
  241. package/dist/dataParser/parsers/templateLiteral.d.ts +0 -49
  242. package/dist/dataParser/parsers/templateLiteral.mjs +0 -44
@@ -4,11 +4,11 @@ var unwrap = require('../../common/unwrap.cjs');
4
4
  require('../../common/globalStore.cjs');
5
5
  require('../../common/builder.cjs');
6
6
  var kind = require('../kind.cjs');
7
- var base = require('./base.cjs');
8
- var create$1 = require('./create.cjs');
9
7
  var is$1 = require('../left/is.cjs');
10
8
  var create = require('../right/create.cjs');
11
9
  var is = require('../right/is.cjs');
10
+ var create$1 = require('./create.cjs');
11
+ var base = require('./base.cjs');
12
12
 
13
13
  const eitherOptionalFilledKind = kind.createEitherKind("optional-filled");
14
14
  function optionalFilled(value) {
@@ -12,6 +12,6 @@ type Either = EitherRight | EitherLeft;
12
12
  export declare function optionalFilled<const GenericValue extends unknown>(value: GenericValue): EitherOptionalFilled<GenericValue>;
13
13
  export declare function isOptionalFilled<GenericInput extends unknown>(input: GenericInput): input is Extract<GenericInput, EitherOptionalFilled>;
14
14
  type ToOptionalEither<GenericValue extends unknown> = GenericValue extends Either ? GenericValue : ReturnType<typeof optional<GenericValue>>;
15
- export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<BreakGenericLink<GenericInput>>, EitherOptionalFilled>;
16
- export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<GenericInput>, EitherOptionalFilled>>) => GenericOutput): GenericOutput | Exclude<ToOptionalEither<GenericInput>, EitherOptionalFilled>;
15
+ export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>, EitherOptionalFilled>>) => GenericOutput): (input: GenericInput) => GenericOutput | Exclude<ToOptionalEither<BreakGenericLink<GenericInput>>, EitherOptionalFilled>;
16
+ export declare function whenIsOptionalFilled<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<ToOptionalEither<BreakGenericLink<GenericInput>>, EitherOptionalFilled>>) => GenericOutput): GenericOutput | Exclude<ToOptionalEither<GenericInput>, EitherOptionalFilled>;
17
17
  export {};
@@ -2,11 +2,11 @@ import { unwrap } from '../../common/unwrap.mjs';
2
2
  import '../../common/globalStore.mjs';
3
3
  import '../../common/builder.mjs';
4
4
  import { createEitherKind } from '../kind.mjs';
5
- import { eitherOptionalKind } from './base.mjs';
6
- import { optional } from './create.mjs';
7
5
  import { isLeft } from '../left/is.mjs';
8
6
  import { right } from '../right/create.mjs';
9
7
  import { isRight } from '../right/is.mjs';
8
+ import { optional } from './create.mjs';
9
+ import { eitherOptionalKind } from './base.mjs';
10
10
 
11
11
  const eitherOptionalFilledKind = createEitherKind("optional-filled");
12
12
  function optionalFilled(value) {
@@ -3,10 +3,10 @@
3
3
  var unwrap = require('../../common/unwrap.cjs');
4
4
  require('../../common/globalStore.cjs');
5
5
  require('../../common/builder.cjs');
6
- var is = require('../left/is.cjs');
7
6
  var create = require('../future/create.cjs');
8
7
  var success = require('./success.cjs');
9
8
  var is$1 = require('./is.cjs');
9
+ var is = require('../left/is.cjs');
10
10
 
11
11
  function rightAsyncPipe(input, ...pipes) {
12
12
  return create.future((async () => {
@@ -1,10 +1,10 @@
1
1
  import { unwrap } from '../../common/unwrap.mjs';
2
2
  import '../../common/globalStore.mjs';
3
3
  import '../../common/builder.mjs';
4
- import { isLeft } from '../left/is.mjs';
5
4
  import { future } from '../future/create.mjs';
6
5
  import { success } from './success.mjs';
7
6
  import { isRight } from './is.mjs';
7
+ import { isLeft } from '../left/is.mjs';
8
8
 
9
9
  function rightAsyncPipe(input, ...pipes) {
10
10
  return future((async () => {
@@ -3,9 +3,9 @@
3
3
  var unwrap = require('../../common/unwrap.cjs');
4
4
  require('../../common/globalStore.cjs');
5
5
  require('../../common/builder.cjs');
6
- var is = require('../left/is.cjs');
7
6
  var success = require('./success.cjs');
8
7
  var is$1 = require('./is.cjs');
8
+ var is = require('../left/is.cjs');
9
9
 
10
10
  /* eslint-disable @typescript-eslint/max-params */
11
11
  function rightPipe(input, ...pipes) {
@@ -1,9 +1,9 @@
1
1
  import { unwrap } from '../../common/unwrap.mjs';
2
2
  import '../../common/globalStore.mjs';
3
3
  import '../../common/builder.mjs';
4
- import { isLeft } from '../left/is.mjs';
5
4
  import { success } from './success.mjs';
6
5
  import { isRight } from './is.mjs';
6
+ import { isLeft } from '../left/is.mjs';
7
7
 
8
8
  /* eslint-disable @typescript-eslint/max-params */
9
9
  function rightPipe(input, ...pipes) {
@@ -1,4 +1,4 @@
1
1
  import { type EscapeVoid, type AnyValue, type Unwrap, type BreakGenericLink } from "../../common";
2
2
  import { type EitherRight } from "./create";
3
- export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherRight>>) => GenericOutput): (input: GenericInput) => Exclude<BreakGenericLink<GenericInput>, EitherRight> | GenericOutput;
4
- export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<GenericInput, EitherRight>>) => GenericOutput): Exclude<GenericInput, EitherRight> | GenericOutput;
3
+ export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(theFunction: (eitherValue: Unwrap<Extract<BreakGenericLink<GenericInput>, EitherRight>>) => GenericOutput): (input: GenericInput) => Exclude<BreakGenericLink<GenericInput>, EitherRight> | GenericOutput;
4
+ export declare function whenIsRight<const GenericInput extends unknown, const GenericOutput extends AnyValue | EscapeVoid>(input: GenericInput, theFunction: (eitherValue: Unwrap<Extract<BreakGenericLink<GenericInput>, EitherRight>>) => GenericOutput): Exclude<GenericInput, EitherRight> | GenericOutput;
@@ -15,7 +15,7 @@ function asyncReduce(...args) {
15
15
  return (async () => {
16
16
  let index = 0;
17
17
  for await (const element of iterator) {
18
- const result = theFunction({
18
+ const result = await theFunction({
19
19
  element,
20
20
  index,
21
21
  lastValue,
@@ -1,3 +1,4 @@
1
- import { type GeneratorReduceFromValue, type GeneratorEligibleReduceFromValue, type GeneratorReduceExitOrNext, type GeneratorReduceFunctionParams } from "./reduce";
2
- export declare function asyncReduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue>(startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => GeneratorReduceExitOrNext<GeneratorReduceFromValue<GenericReduceFrom>>): (iterator: Iterable<GenericElement> | AsyncIterable<GenericElement>) => Promise<GeneratorReduceFromValue<GenericReduceFrom>>;
3
- export declare function asyncReduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue>(iterator: Iterable<GenericElement> | AsyncIterable<GenericElement>, startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => GeneratorReduceExitOrNext<GeneratorReduceFromValue<GenericReduceFrom>>): Promise<GeneratorReduceFromValue<GenericReduceFrom>>;
1
+ import { type GeneratorReduceFromValue, type GeneratorEligibleReduceFromValue, type GeneratorReduceFunctionParams, type GeneratorReduceExit, type GeneratorReduceNext } from "./reduce";
2
+ import { type IsEqual, type MaybePromise } from "../common";
3
+ export declare function asyncReduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue, GenericExit extends GeneratorReduceExit = GeneratorReduceExit<never>>(startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => MaybePromise<GeneratorReduceNext<GeneratorReduceFromValue<GenericReduceFrom>> | GenericExit>): (iterator: Iterable<GenericElement> | AsyncIterable<GenericElement>) => Promise<GeneratorReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, GeneratorReduceExit> extends true ? never : GenericExit["-exit"])>;
4
+ export declare function asyncReduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue, GenericExit extends GeneratorReduceExit = GeneratorReduceExit<never>>(iterator: Iterable<GenericElement> | AsyncIterable<GenericElement>, startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => MaybePromise<GeneratorReduceNext<GeneratorReduceFromValue<GenericReduceFrom>> | GenericExit>): Promise<GeneratorReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, GeneratorReduceExit> extends true ? never : GenericExit["-exit"])>;
@@ -13,7 +13,7 @@ function asyncReduce(...args) {
13
13
  return (async () => {
14
14
  let index = 0;
15
15
  for await (const element of iterator) {
16
- const result = theFunction({
16
+ const result = await theFunction({
17
17
  element,
18
18
  index,
19
19
  lastValue,
@@ -1,21 +1,20 @@
1
1
  import { type Kind } from "../common/kind";
2
2
  import { type WrappedValue } from "../common/wrapValue";
3
3
  import { type Unwrap } from "../common/unwrap";
4
- import { type ToLargeEnsemble } from "../common";
5
- interface GeneratorReduceNext<GenericOutput extends unknown> {
4
+ import { type IsEqual, type ToLargeEnsemble } from "../common";
5
+ export interface GeneratorReduceNext<GenericOutput extends unknown = unknown> {
6
6
  "-next": GenericOutput;
7
7
  }
8
- interface GeneratorReduceExit<GenericOutput extends unknown> {
8
+ export interface GeneratorReduceExit<GenericOutput extends unknown = unknown> {
9
9
  "-exit": GenericOutput;
10
10
  }
11
- export type GeneratorReduceExitOrNext<GenericOutput extends unknown = unknown> = GeneratorReduceExit<GenericOutput> | GeneratorReduceNext<GenericOutput>;
12
11
  export interface GeneratorReduceFunctionParams<GenericElement extends unknown = unknown, GenericOutput extends unknown = unknown> {
13
12
  element: GenericElement;
14
13
  index: number;
15
14
  lastValue: GenericOutput;
16
15
  nextWithObject: GenericOutput extends object ? (object1: GenericOutput, object2: Partial<GenericOutput>) => GeneratorReduceNext<GenericOutput> : undefined;
17
16
  next(output: GenericOutput): GeneratorReduceNext<GenericOutput>;
18
- exit(output: GenericOutput): GeneratorReduceExit<GenericOutput>;
17
+ exit<GenericExitValue extends unknown>(output: GenericExitValue): GeneratorReduceExit<GenericExitValue>;
19
18
  }
20
19
  declare const generatorReduceFromKind: import("../common").KindHandler<import("../common").KindDefinition<"generator-reduce-from", unknown>>;
21
20
  export interface GeneratorReduceFromResult<GenericValue extends unknown = unknown> extends Kind<typeof generatorReduceFromKind.definition>, WrappedValue<GenericValue> {
@@ -23,6 +22,6 @@ export interface GeneratorReduceFromResult<GenericValue extends unknown = unknow
23
22
  export declare function reduceFrom<GenericValue extends unknown>(value: GenericValue): GeneratorReduceFromResult<GenericValue>;
24
23
  export type GeneratorEligibleReduceFromValue = number | string | bigint | boolean | GeneratorReduceFromResult;
25
24
  export type GeneratorReduceFromValue<GenericValue extends GeneratorEligibleReduceFromValue> = GenericValue extends GeneratorReduceFromResult ? Unwrap<GenericValue> : ToLargeEnsemble<GenericValue>;
26
- export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue>(startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => GeneratorReduceExitOrNext<GeneratorReduceFromValue<GenericReduceFrom>>): (iterator: Iterable<GenericElement>) => GeneratorReduceFromValue<GenericReduceFrom>;
27
- export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue>(iterator: Iterable<GenericElement>, startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => GeneratorReduceExitOrNext<GeneratorReduceFromValue<GenericReduceFrom>>): GeneratorReduceFromValue<GenericReduceFrom>;
25
+ export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue, GenericExit extends GeneratorReduceExit = GeneratorReduceExit<never>>(startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => GeneratorReduceNext<GeneratorReduceFromValue<GenericReduceFrom>> | GenericExit): (iterator: Iterable<GenericElement>) => GeneratorReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, GeneratorReduceExit> extends true ? never : GenericExit["-exit"]);
26
+ export declare function reduce<GenericElement extends unknown, GenericReduceFrom extends GeneratorEligibleReduceFromValue, GenericExit extends GeneratorReduceExit = GeneratorReduceExit<never>>(iterator: Iterable<GenericElement>, startValue: GenericReduceFrom, theFunction: (params: GeneratorReduceFunctionParams<GenericElement, GeneratorReduceFromValue<GenericReduceFrom>>) => GeneratorReduceNext<GeneratorReduceFromValue<GenericReduceFrom>> | GenericExit): GeneratorReduceFromValue<GenericReduceFrom> | (IsEqual<GenericExit, GeneratorReduceExit> extends true ? never : GenericExit["-exit"]);
28
27
  export {};
package/dist/index.cjs CHANGED
@@ -39,6 +39,7 @@ var memo = require('./common/memo.cjs');
39
39
  var instanceOf = require('./common/instanceOf.cjs');
40
40
  var globalStore = require('./common/globalStore.cjs');
41
41
  var builder = require('./common/builder.cjs');
42
+ var createKindIdentifier = require('./common/createKindIdentifier.cjs');
42
43
  var index = require('./array/index.cjs');
43
44
  var index$1 = require('./number/index.cjs');
44
45
  var index$2 = require('./either/index.cjs');
@@ -103,6 +104,7 @@ exports.createGlobalStore = globalStore.createGlobalStore;
103
104
  exports.MissingBuilderMethodsError = builder.MissingBuilderMethodsError;
104
105
  exports.builderKind = builder.builderKind;
105
106
  exports.createBuilder = builder.createBuilder;
107
+ exports.createKindIdentifier = createKindIdentifier.createKindIdentifier;
106
108
  exports.A = index;
107
109
  exports.DArray = index;
108
110
  exports.DNumber = index$1;
package/dist/index.mjs CHANGED
@@ -37,6 +37,7 @@ export { memo } from './common/memo.mjs';
37
37
  export { instanceOf } from './common/instanceOf.mjs';
38
38
  export { createGlobalStore } from './common/globalStore.mjs';
39
39
  export { MissingBuilderMethodsError, builderKind, createBuilder } from './common/builder.mjs';
40
+ export { createKindIdentifier } from './common/createKindIdentifier.mjs';
40
41
  import * as index from './array/index.mjs';
41
42
  export { index as A };
42
43
  export { index as DArray };
@@ -1,7 +1,8 @@
1
+ import { type DString } from "..";
1
2
  import { type IsEqual, type ObjectEntry, type ObjectKey } from "../common";
2
3
  import { type SimplifyTopLevel } from "../common/types/simplifyTopLevel";
3
4
  export type GetEntry<GenericKey extends ObjectKey, GenericValue extends unknown> = GenericValue extends any ? GenericKey extends string | number ? [`${GenericKey}`, GenericValue] : never : never;
4
- export type GetEntries<GenericObject extends object> = ({
5
+ export type GetEntries<GenericObject extends object> = GenericObject extends readonly any[] ? [DString.Number, GenericObject[number]][] : ({
5
6
  [Prop in keyof GenericObject]-?: GetEntry<Prop, GenericObject[Prop]>;
6
7
  }[keyof GenericObject]) extends infer InferredResult extends ObjectEntry ? IsEqual<InferredResult, never> extends true ? [] : InferredResult[] : never;
7
8
  export declare function entries<GenericObject extends object>(object: GenericObject): SimplifyTopLevel<GetEntries<GenericObject>>;
@@ -1,7 +1,14 @@
1
1
  'use strict';
2
2
 
3
+ var kind = require('../common/kind.cjs');
4
+ var wrapValue = require('../common/wrapValue.cjs');
5
+ require('../common/globalStore.cjs');
6
+ require('../common/builder.cjs');
7
+
3
8
  function values(object) {
4
- return Object.values(object);
9
+ return Object.entries(object)
10
+ .filter(([key]) => !wrapValue.isRuntimeWrappedValueKey(key) && !kind.isRuntimeKind(key))
11
+ .map(([, value]) => value);
5
12
  }
6
13
 
7
14
  exports.values = values;
@@ -1,4 +1,2 @@
1
1
  import { type AnyValue } from "../common/types/anyValue";
2
- export declare function values<GenericValue extends AnyValue>(object: {
3
- [key: string]: GenericValue;
4
- } | ArrayLike<GenericValue>): GenericValue[];
2
+ export declare function values<GenericValue extends AnyValue>(object: Record<string, GenericValue>): GenericValue[];
@@ -1,5 +1,12 @@
1
+ import { isRuntimeKind } from '../common/kind.mjs';
2
+ import { isRuntimeWrappedValueKey } from '../common/wrapValue.mjs';
3
+ import '../common/globalStore.mjs';
4
+ import '../common/builder.mjs';
5
+
1
6
  function values(object) {
2
- return Object.values(object);
7
+ return Object.entries(object)
8
+ .filter(([key]) => !isRuntimeWrappedValueKey(key) && !isRuntimeKind(key))
9
+ .map(([, value]) => value);
3
10
  }
4
11
 
5
12
  export { values };
@@ -9,3 +9,4 @@ export * from "./stringLength";
9
9
  export * from "./forbiddenString";
10
10
  export * from "./number";
11
11
  export * from "./digit";
12
+ export * from "./templateLiteralContainLargeType";
@@ -0,0 +1,5 @@
1
+ import { type IsEqual, type Or } from "../../common";
2
+ export type TemplateLiteralContainLargeType<GenericValue extends string> = (GenericValue extends `${infer InferredFirst}${infer InferredLast}` ? Or<[
3
+ IsEqual<InferredFirst, `${number}`>,
4
+ IsEqual<InferredFirst, `${bigint}`>
5
+ ]> extends false ? TemplateLiteralContainLargeType<InferredLast> : true : GenericValue extends "" ? false : true) extends false ? false : true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duplojs/utils",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "author": "mathcovax",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "url": "git+https://github.com/duplojs/utils.git"
10
10
  },
11
11
  "scripts": {
12
- "build": "rollup --config && tsc-alias -p tsconfig.build.json",
12
+ "build": "rollup --config",
13
13
  "test:tu": "vitest --coverage",
14
14
  "test:tu:bench": "vitest bench",
15
15
  "test:tu:watch": "vitest --coverage --watch",
@@ -98,7 +98,7 @@
98
98
  "rollup": "4.50.0",
99
99
  "rollup-plugin-delete": "3.0.1",
100
100
  "rollup-plugin-esbuild": "6.2.1",
101
- "tsc-alias": "1.8.16",
101
+ "rollup-plugin-tsc-alias": "1.1.4",
102
102
  "tslib": "2.8.1",
103
103
  "tsx": "4.20.5",
104
104
  "typescript": "5.9.2",
@@ -1,30 +0,0 @@
1
- import { type NeverCoalescing, type Kind } from "../../common";
2
- import { type DataParserDefinition, type DataParser, type Output, type Input } from "../base";
3
- import { type MergeDefinition } from "../../dataParser/types";
4
- import { type DataParserString } from "./string";
5
- import { type DataParserTemplateLiteral } from "./templateLiteral";
6
- import { type DataParserDefinitionLiteral, type DataParserLiteral } from "./literal";
7
- import { type DataParserDefinitionNumber, type DataParserNumber } from "./number";
8
- import { type DataParserDefinitionUnion, type DataParserUnion } from "./union";
9
- export type DataParserRecordKey = (DataParserString | DataParserTemplateLiteral | DataParserLiteral<DataParserDefinitionLiteral & {
10
- value: string[];
11
- }> | DataParserNumber<DataParserDefinitionNumber & {
12
- coerce: true;
13
- }> | DataParserUnion<DataParserDefinitionUnion & {
14
- options: DataParserRecordKey[];
15
- }>);
16
- export interface DataParserDefinitionRecord extends DataParserDefinition<never> {
17
- readonly key: DataParserRecordKey;
18
- readonly value: DataParser;
19
- }
20
- export declare const recordKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/record", unknown>>;
21
- export type DataParserRecordShapeOutput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser> = Extract<Record<Output<GenericDataParserKey> extends infer InferredKey extends string | number ? `${InferredKey}` : never, Output<GenericDataParserValue> extends infer InferredValue ? InferredValue : never>, any>;
22
- export type DataParserRecordShapeInput<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser> = Extract<Record<Input<GenericDataParserKey> extends infer InferredKey extends string | number ? InferredKey : never, Input<GenericDataParserValue> extends infer InferredValue ? InferredValue : never>, any>;
23
- type _DataParserRecord<GenericDefinition extends DataParserDefinitionRecord> = (DataParser<GenericDefinition, DataParserRecordShapeOutput<GenericDefinition["key"], GenericDefinition["value"]> extends infer InferredOutput ? InferredOutput : never, DataParserRecordShapeInput<GenericDefinition["key"], GenericDefinition["value"]>> & Kind<typeof recordKind.definition>);
24
- export interface DataParserRecord<GenericDefinition extends DataParserDefinitionRecord = DataParserDefinitionRecord> extends _DataParserRecord<GenericDefinition> {
25
- }
26
- export declare function record<GenericDataParserKey extends DataParserRecordKey, GenericDataParserValue extends DataParser, const GenericDefinition extends Partial<DataParserDefinitionRecord> = never>(key: GenericDataParserKey, value: GenericDataParserValue, definition?: GenericDefinition): DataParserRecord<MergeDefinition<DataParserDefinitionRecord, NeverCoalescing<GenericDefinition, {}> & {
27
- key: GenericDataParserKey;
28
- value: GenericDataParserValue;
29
- }>>;
30
- export {};
@@ -1,47 +0,0 @@
1
- 'use strict';
2
-
3
- var escapeRegExp = require('../../common/escapeRegExp.cjs');
4
- var pipe = require('../../common/pipe.cjs');
5
- var innerPipe = require('../../common/innerPipe.cjs');
6
- var when$1 = require('../../common/when.cjs');
7
- var isType = require('../../common/isType.cjs');
8
- var whenElse = require('../../common/whenElse.cjs');
9
- var map = require('../../array/map.cjs');
10
- var join = require('../../array/join.cjs');
11
- require('../../common/globalStore.cjs');
12
- require('../../common/builder.cjs');
13
- var base = require('../base.cjs');
14
- var error = require('../error.cjs');
15
- require('../../pattern/result.cjs');
16
- var exhaustive = require('../../pattern/exhaustive.cjs');
17
- var when = require('../../pattern/when.cjs');
18
- var replace = require('../../string/replace.cjs');
19
- var index = require('./string/index.cjs');
20
- var index$2 = require('./number/index.cjs');
21
- var index$1 = require('./bigint/index.cjs');
22
- var literal = require('./literal.cjs');
23
- var empty = require('./empty.cjs');
24
- var nil = require('./nil.cjs');
25
- var boolean = require('./boolean.cjs');
26
- var kind = require('../kind.cjs');
27
-
28
- const templateLiteralKind = kind.createDataParserKind("template-literal");
29
- function templateLiteral(template, definition) {
30
- const pattern = pipe.pipe(template, map.map(innerPipe.innerPipe(when.when(isType.isType("string"), (value) => `(?:${escapeRegExp.escapeRegExp(value)})`), when.when(index$2.numberKind.has, () => "(:?[0-9]+)"), when.when(index$1.bigIntKind.has, () => "(?:[0-9]+n)"), when.when(boolean.booleanKind.has, () => "(?:true|false)"), when.when(nil.nilKind.has, () => "(?:null)"), when.when(empty.emptyKind.has, () => "(?:undefined)"), when.when(literal.literalKind.has, (dataParser) => pipe.pipe(dataParser.definition.value, map.map(innerPipe.innerPipe(when$1.when(isType.isType("bigint"), (value) => `${value}n`), String, escapeRegExp.escapeRegExp)), join.join("|"), (pattern) => `(?:${pattern})`)), when.when(index.stringKind.has, innerPipe.innerPipe(whenElse.whenElse((dataParser) => !!dataParser.definition.checkers.length, (dataParser) => pipe.pipe(dataParser.definition.checkers, map.map((element) => pipe.pipe(element.definition.pattern.source, replace.replace(/^\^/, ""), replace.replace(/\$$/, ""))), join.join("")), () => "(?:[^]*)"))), when.when(templateLiteralKind.has, (dataParser) => pipe.pipe(dataParser.definition.pattern.source, replace.replace(/^\^/, ""), replace.replace(/\$$/, ""), (pattern) => `(?:${pattern})`)), exhaustive.exhaustive)), join.join(""), (pattern) => new RegExp(`^${pattern}$`));
31
- return base.dataParserInit(templateLiteralKind, {
32
- definition: {
33
- errorMessage: definition?.errorMessage,
34
- checkers: definition?.checkers ?? [],
35
- template,
36
- pattern,
37
- },
38
- }, (data, _error, self) => {
39
- if (typeof data === "string" && self.definition.pattern.test(data)) {
40
- return data;
41
- }
42
- return error.SymbolDataParserErrorIssue;
43
- });
44
- }
45
-
46
- exports.templateLiteral = templateLiteral;
47
- exports.templateLiteralKind = templateLiteralKind;
@@ -1,49 +0,0 @@
1
- import { type Adaptor, type Kind, type NeverCoalescing } from "../../common";
2
- import { type DataParserDefinition, type DataParser, type Output, type Input } from "../base";
3
- import { type MergeDefinition } from "../../dataParser/types";
4
- import { type DataParserCheckerEmail, type DataParserDefinitionString, type DataParserString } from "./string";
5
- import { type DataParserDefinitionNumber, type DataParserNumber } from "./number";
6
- import { type DataParserDefinitionBigInt, type DataParserBigInt } from "./bigint";
7
- import { type DataParserDefinitionLiteral, type DataParserLiteral } from "./literal";
8
- import { type DataParserDefinitionEmpty, type DataParserEmpty } from "./empty";
9
- import { type DataParserDefinitionNil, type DataParserNil } from "./nil";
10
- import { type DataParserDefinitionBoolean, type DataParserBoolean } from "./boolean";
11
- export type DataParsersTemplateLiteral = (string | DataParserString<DataParserDefinitionString & {
12
- readonly checkers: readonly (DataParserCheckerEmail)[];
13
- }> | DataParserNumber<DataParserDefinitionNumber & {
14
- readonly checkers: readonly [];
15
- }> | DataParserBigInt<DataParserDefinitionBigInt & {
16
- readonly checkers: readonly [];
17
- }> | DataParserBoolean<DataParserDefinitionBoolean & {
18
- readonly checkers: readonly [];
19
- }> | DataParserLiteral<DataParserDefinitionLiteral & {
20
- readonly checkers: readonly [];
21
- }> | DataParserEmpty<DataParserDefinitionEmpty & {
22
- readonly checkers: readonly [];
23
- }> | DataParserNil<DataParserDefinitionNil & {
24
- readonly checkers: readonly [];
25
- }> | DataParserTemplateLiteral<DataParserDefinitionTemplateLiteral & {
26
- readonly checkers: readonly [];
27
- }>);
28
- export type TemplateLiteralShape = readonly [DataParsersTemplateLiteral, ...DataParsersTemplateLiteral[]];
29
- type EligibleTemplateLiteral = string | number | bigint | boolean | null | undefined;
30
- export type TemplateLiteralShapeOutput<GenericTemplate extends TemplateLiteralShape, GenericLastResult extends string = ""> = GenericTemplate extends readonly [
31
- infer InferredFirst extends DataParsersTemplateLiteral,
32
- ...infer InferredRest extends DataParsersTemplateLiteral[]
33
- ] ? (`${GenericLastResult}${InferredFirst extends string ? InferredFirst : Adaptor<Output<Exclude<InferredFirst, string>>, EligibleTemplateLiteral>}`) extends infer InferredResult extends string ? InferredRest extends readonly [] ? InferredResult : InferredRest extends TemplateLiteralShape ? TemplateLiteralShapeOutput<InferredRest, InferredResult> : TemplateLiteralShapeOutput<[InferredRest[number]], InferredResult> : never : never;
34
- export type TemplateLiteralShapeInput<GenericTemplate extends TemplateLiteralShape, GenericLastResult extends string = ""> = GenericTemplate extends readonly [
35
- infer InferredFirst extends DataParsersTemplateLiteral,
36
- ...infer InferredRest extends DataParsersTemplateLiteral[]
37
- ] ? (`${GenericLastResult}${InferredFirst extends string ? InferredFirst : Adaptor<Input<Exclude<InferredFirst, string>>, EligibleTemplateLiteral>}`) extends infer InferredResult extends string ? InferredRest extends readonly [] ? InferredResult : InferredRest extends TemplateLiteralShape ? TemplateLiteralShapeInput<InferredRest, InferredResult> : TemplateLiteralShapeInput<[InferredRest[number]], InferredResult> : never : never;
38
- export interface DataParserDefinitionTemplateLiteral extends DataParserDefinition<never> {
39
- readonly template: TemplateLiteralShape;
40
- readonly pattern: RegExp;
41
- }
42
- export declare const templateLiteralKind: import("../../common").KindHandler<import("../../common").KindDefinition<"@DuplojsUtilsDataParser/template-literal", unknown>>;
43
- type _DataParserTemplateLiteral<GenericDefinition extends DataParserDefinitionTemplateLiteral> = (DataParser<GenericDefinition, TemplateLiteralShapeOutput<GenericDefinition["template"]>, TemplateLiteralShapeInput<GenericDefinition["template"]>> & Kind<typeof templateLiteralKind.definition>);
44
- export interface DataParserTemplateLiteral<GenericDefinition extends DataParserDefinitionTemplateLiteral = DataParserDefinitionTemplateLiteral> extends _DataParserTemplateLiteral<GenericDefinition> {
45
- }
46
- export declare function templateLiteral<const GenericTemplate extends TemplateLiteralShape, const GenericDefinition extends Partial<Omit<DataParserDefinitionTemplateLiteral, "template" | "pattern">> = never>(template: GenericTemplate, definition?: GenericDefinition): DataParserTemplateLiteral<MergeDefinition<DataParserDefinitionTemplateLiteral, NeverCoalescing<GenericDefinition, {}> & {
47
- template: GenericTemplate;
48
- }>>;
49
- export {};
@@ -1,44 +0,0 @@
1
- import { escapeRegExp } from '../../common/escapeRegExp.mjs';
2
- import { pipe } from '../../common/pipe.mjs';
3
- import { innerPipe } from '../../common/innerPipe.mjs';
4
- import { when as when$1 } from '../../common/when.mjs';
5
- import { isType } from '../../common/isType.mjs';
6
- import { whenElse } from '../../common/whenElse.mjs';
7
- import { map } from '../../array/map.mjs';
8
- import { join } from '../../array/join.mjs';
9
- import '../../common/globalStore.mjs';
10
- import '../../common/builder.mjs';
11
- import { dataParserInit } from '../base.mjs';
12
- import { SymbolDataParserErrorIssue } from '../error.mjs';
13
- import '../../pattern/result.mjs';
14
- import { exhaustive } from '../../pattern/exhaustive.mjs';
15
- import { when } from '../../pattern/when.mjs';
16
- import { replace } from '../../string/replace.mjs';
17
- import { stringKind } from './string/index.mjs';
18
- import { numberKind } from './number/index.mjs';
19
- import { bigIntKind } from './bigint/index.mjs';
20
- import { literalKind } from './literal.mjs';
21
- import { emptyKind } from './empty.mjs';
22
- import { nilKind } from './nil.mjs';
23
- import { booleanKind } from './boolean.mjs';
24
- import { createDataParserKind } from '../kind.mjs';
25
-
26
- const templateLiteralKind = createDataParserKind("template-literal");
27
- function templateLiteral(template, definition) {
28
- const pattern = pipe(template, map(innerPipe(when(isType("string"), (value) => `(?:${escapeRegExp(value)})`), when(numberKind.has, () => "(:?[0-9]+)"), when(bigIntKind.has, () => "(?:[0-9]+n)"), when(booleanKind.has, () => "(?:true|false)"), when(nilKind.has, () => "(?:null)"), when(emptyKind.has, () => "(?:undefined)"), when(literalKind.has, (dataParser) => pipe(dataParser.definition.value, map(innerPipe(when$1(isType("bigint"), (value) => `${value}n`), String, escapeRegExp)), join("|"), (pattern) => `(?:${pattern})`)), when(stringKind.has, innerPipe(whenElse((dataParser) => !!dataParser.definition.checkers.length, (dataParser) => pipe(dataParser.definition.checkers, map((element) => pipe(element.definition.pattern.source, replace(/^\^/, ""), replace(/\$$/, ""))), join("")), () => "(?:[^]*)"))), when(templateLiteralKind.has, (dataParser) => pipe(dataParser.definition.pattern.source, replace(/^\^/, ""), replace(/\$$/, ""), (pattern) => `(?:${pattern})`)), exhaustive)), join(""), (pattern) => new RegExp(`^${pattern}$`));
29
- return dataParserInit(templateLiteralKind, {
30
- definition: {
31
- errorMessage: definition?.errorMessage,
32
- checkers: definition?.checkers ?? [],
33
- template,
34
- pattern,
35
- },
36
- }, (data, _error, self) => {
37
- if (typeof data === "string" && self.definition.pattern.test(data)) {
38
- return data;
39
- }
40
- return SymbolDataParserErrorIssue;
41
- });
42
- }
43
-
44
- export { templateLiteral, templateLiteralKind };