@daiso-tech/core 0.12.0 → 0.13.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 (72) hide show
  1. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +1 -1
  2. package/dist/cjs/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  3. package/dist/cjs/cache/implementations/derivables/base-cache.js +8 -8
  4. package/dist/cjs/cache/implementations/derivables/base-cache.js.map +1 -1
  5. package/dist/cjs/collection/contracts/_module.js +1 -0
  6. package/dist/cjs/collection/contracts/_module.js.map +1 -1
  7. package/dist/cjs/collection/contracts/_shared.js +0 -43
  8. package/dist/cjs/collection/contracts/_shared.js.map +1 -1
  9. package/dist/cjs/collection/contracts/collection.errors.js +46 -0
  10. package/dist/cjs/collection/contracts/collection.errors.js.map +1 -0
  11. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
  12. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-entries-iterable.js.map +1 -1
  13. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-update-iterable.js +3 -3
  14. package/dist/cjs/collection/implementations/async-iterable-collection/_shared/async-zip-iterable.js.map +1 -1
  15. package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js +38 -1
  16. package/dist/cjs/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  17. package/dist/cjs/collection/implementations/iterable-collection/_shared/count-by-iterable.js.map +1 -1
  18. package/dist/cjs/collection/implementations/iterable-collection/_shared/entries-iterable.js.map +1 -1
  19. package/dist/cjs/collection/implementations/iterable-collection/_shared/group-by-iterable.js.map +1 -1
  20. package/dist/cjs/collection/implementations/iterable-collection/_shared/update-iterable.js +3 -3
  21. package/dist/cjs/collection/implementations/iterable-collection/_shared/zip-iterable.js.map +1 -1
  22. package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js +34 -1
  23. package/dist/cjs/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  24. package/dist/cjs/collection/implementations/list-collection/list-collection.js +34 -1
  25. package/dist/cjs/collection/implementations/list-collection/list-collection.js.map +1 -1
  26. package/dist/cjs/serializer/implementations/_shared/test-utilities/serializer.test-suite.js.map +1 -1
  27. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js +1 -1
  28. package/dist/esm/cache/implementations/adapters/memory-cache-adapter/memory-cache-adapter.js.map +1 -1
  29. package/dist/esm/cache/implementations/derivables/base-cache.js +8 -8
  30. package/dist/esm/cache/implementations/derivables/base-cache.js.map +1 -1
  31. package/dist/esm/collection/contracts/_module.js +1 -0
  32. package/dist/esm/collection/contracts/_module.js.map +1 -1
  33. package/dist/esm/collection/contracts/_shared.js +0 -36
  34. package/dist/esm/collection/contracts/_shared.js.map +1 -1
  35. package/dist/esm/collection/contracts/collection.errors.js +37 -0
  36. package/dist/esm/collection/contracts/collection.errors.js.map +1 -0
  37. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-count-by-iterable.js.map +1 -1
  38. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-entries-iterable.js.map +1 -1
  39. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-update-iterable.js +1 -1
  40. package/dist/esm/collection/implementations/async-iterable-collection/_shared/async-zip-iterable.js.map +1 -1
  41. package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js +39 -2
  42. package/dist/esm/collection/implementations/async-iterable-collection/async-iterable-collection.js.map +1 -1
  43. package/dist/esm/collection/implementations/iterable-collection/_shared/count-by-iterable.js.map +1 -1
  44. package/dist/esm/collection/implementations/iterable-collection/_shared/entries-iterable.js.map +1 -1
  45. package/dist/esm/collection/implementations/iterable-collection/_shared/group-by-iterable.js.map +1 -1
  46. package/dist/esm/collection/implementations/iterable-collection/_shared/update-iterable.js +1 -1
  47. package/dist/esm/collection/implementations/iterable-collection/_shared/zip-iterable.js.map +1 -1
  48. package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js +35 -2
  49. package/dist/esm/collection/implementations/iterable-collection/iterable-collection.js.map +1 -1
  50. package/dist/esm/collection/implementations/list-collection/list-collection.js +34 -1
  51. package/dist/esm/collection/implementations/list-collection/list-collection.js.map +1 -1
  52. package/dist/esm/serializer/implementations/_shared/test-utilities/serializer.test-suite.js.map +1 -1
  53. package/dist/types/_shared/types.d.ts +0 -1
  54. package/dist/types/collection/contracts/_module.d.ts +1 -0
  55. package/dist/types/collection/contracts/_shared.d.ts +2 -36
  56. package/dist/types/collection/contracts/async-collection.contract.d.ts +39 -60
  57. package/dist/types/collection/contracts/collection.contract.d.ts +36 -55
  58. package/dist/types/collection/contracts/collection.errors.d.ts +39 -0
  59. package/dist/types/collection/implementations/async-iterable-collection/_shared/async-count-by-iterable.d.ts +2 -3
  60. package/dist/types/collection/implementations/async-iterable-collection/_shared/async-entries-iterable.d.ts +2 -3
  61. package/dist/types/collection/implementations/async-iterable-collection/_shared/async-group-by-iterable.d.ts +6 -3
  62. package/dist/types/collection/implementations/async-iterable-collection/_shared/async-update-iterable.d.ts +1 -1
  63. package/dist/types/collection/implementations/async-iterable-collection/_shared/async-zip-iterable.d.ts +2 -3
  64. package/dist/types/collection/implementations/async-iterable-collection/async-iterable-collection.d.ts +8 -6
  65. package/dist/types/collection/implementations/iterable-collection/_shared/count-by-iterable.d.ts +2 -3
  66. package/dist/types/collection/implementations/iterable-collection/_shared/entries-iterable.d.ts +2 -3
  67. package/dist/types/collection/implementations/iterable-collection/_shared/group-by-iterable.d.ts +2 -3
  68. package/dist/types/collection/implementations/iterable-collection/_shared/update-iterable.d.ts +1 -1
  69. package/dist/types/collection/implementations/iterable-collection/_shared/zip-iterable.d.ts +2 -3
  70. package/dist/types/collection/implementations/iterable-collection/iterable-collection.d.ts +8 -6
  71. package/dist/types/collection/implementations/list-collection/list-collection.d.ts +7 -5
  72. package/package.json +1 -1
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * @module Collection
3
3
  */
4
- import type { Comparator, Predicate, ForEach, Map, Modifier, Tap, Transform, Reduce, CrossJoinResult } from "../../collection/contracts/_shared";
5
- import type { Lazyable, RecordItem } from "../../_shared/types";
4
+ import type { Comparator, Predicate, ForEach, Map, Modifier, Tap, Transform, Reduce, CrossJoinResult, EnsureMap, EnsureRecord } from "../../collection/contracts/_module";
5
+ import type { Lazyable } from "../../_shared/types";
6
6
  export type Collapse<TValue> = TValue extends Array<infer TItem> | Iterable<infer TItem> | ICollection<infer TItem> ? TItem : TValue;
7
7
  /**
8
8
  * The <i>ICollection</i> contract offers a fluent and efficient approach to working with {@link Iterable} objects.
9
9
  * <i>ICollection</i> is immutable.
10
10
  * @group Contracts
11
+ * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
11
12
  */
12
- export type ICollection<TInput> = Iterable<TInput> & {
13
+ export type ICollection<TInput = unknown> = Iterable<TInput> & {
13
14
  /**
14
15
  * The <i>toIterator</i> method converts the collection to a new iterator.
15
16
  */
@@ -17,7 +18,7 @@ export type ICollection<TInput> = Iterable<TInput> & {
17
18
  /**
18
19
  * The <i>entries</i> returns an ICollection of key, value pairs for every entry in the collection.
19
20
  */
20
- entries(): ICollection<RecordItem<number, TInput>>;
21
+ entries(): ICollection<[number, TInput]>;
21
22
  /**
22
23
  * The <i>keys</i> method returns an ICollection of keys in the collection.
23
24
  */
@@ -194,7 +195,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
194
195
  get(index: number): TInput | null;
195
196
  /**
196
197
  * The <i>getOrFail</i> method returns the item by index. If the item is not found an error will be thrown.
197
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
198
198
  * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
199
199
  * @example
200
200
  * ```ts
@@ -225,6 +225,8 @@ export type ICollection<TInput> = Iterable<TInput> & {
225
225
  /**
226
226
  * The <i>sum</i> method returns the sum of all items in the collection. If the collection includes other than number items an error will be thrown.
227
227
  * If the collection is empty an error will also be thrown.
228
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
229
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
228
230
  * @example
229
231
  * ```ts
230
232
  * import { ListCollection } from "@daiso-tech/core";;
@@ -233,14 +235,13 @@ export type ICollection<TInput> = Iterable<TInput> & {
233
235
  * collection.sum();
234
236
  * // 6
235
237
  * ```
236
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
237
- * @throws {TypeCollectionError} {@link TypeCollectionError}
238
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
239
238
  */
240
239
  sum(): Extract<TInput, number>;
241
240
  /**
242
241
  * The <i>average</i> method returns the average of all items in the collection. If the collection includes other than number items an error will be thrown.
243
242
  * If the collection is empty an error will also be thrown.
243
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
244
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
244
245
  * @example
245
246
  * ```ts
246
247
  * import { ListCollection } from "@daiso-tech/core";;
@@ -249,14 +250,13 @@ export type ICollection<TInput> = Iterable<TInput> & {
249
250
  * collection.average();
250
251
  * // 2
251
252
  * ```
252
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
253
- * @throws {TypeCollectionError} {@link TypeCollectionError}
254
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
255
253
  */
256
254
  average(): Extract<TInput, number>;
257
255
  /**
258
256
  * The <i>median</i> method returns the median of all items in the collection. If the collection includes other than number items an error will be thrown.
259
257
  * If the collection is empty an error will also be thrown.
258
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
259
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
260
260
  * @example
261
261
  * ```ts
262
262
  * import { ListCollection } from "@daiso-tech/core";;
@@ -265,14 +265,13 @@ export type ICollection<TInput> = Iterable<TInput> & {
265
265
  * collection.median();
266
266
  * // 2
267
267
  * ```
268
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
269
- * @throws {TypeCollectionError} {@link TypeCollectionError}
270
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
271
268
  */
272
269
  median(): Extract<TInput, number>;
273
270
  /**
274
271
  * The <i>min</i> method returns the min of all items in the collection. If the collection includes other than number items an error will be thrown.
275
272
  * If the collection is empty an error will also be thrown.
273
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
274
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
276
275
  * @example
277
276
  * ```ts
278
277
  * import { ListCollection } from "@daiso-tech/core";;
@@ -281,14 +280,13 @@ export type ICollection<TInput> = Iterable<TInput> & {
281
280
  * collection.min();
282
281
  * // 1
283
282
  * ```
284
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
285
- * @throws {TypeCollectionError} {@link TypeCollectionError}
286
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
287
283
  */
288
284
  min(): Extract<TInput, number>;
289
285
  /**
290
286
  * The <i>max</i> method returns the max of all items in the collection. If the collection includes other than number items an error will be thrown.
291
287
  * If the collection is empty an error will also be thrown.
288
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
289
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
292
290
  * @example
293
291
  * ```ts
294
292
  * import { ListCollection } from "@daiso-tech/core";;
@@ -297,14 +295,12 @@ export type ICollection<TInput> = Iterable<TInput> & {
297
295
  * collection.max();
298
296
  * // 3
299
297
  * ```
300
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
301
- * @throws {TypeCollectionError} {@link TypeCollectionError}
302
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
303
298
  */
304
299
  max(): Extract<TInput, number>;
305
300
  /**
306
301
  * The <i>percentage</i> method may be used to quickly determine the percentage of items in the collection that pass <i>predicateFn</i>.
307
302
  * If the collection is empty an error will also be thrown.
303
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
308
304
  * @example
309
305
  * ```ts
310
306
  * import { ListCollection } from "@daiso-tech/core";;
@@ -313,8 +309,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
313
309
  * collection.percentage(value => value === 1);
314
310
  * // 33.333
315
311
  * ```
316
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
317
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
318
312
  */
319
313
  percentage(predicateFn: Predicate<TInput, ICollection<TInput>>): number;
320
314
  /**
@@ -327,7 +321,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
327
321
  * collection.some(item => item === 1);
328
322
  * // true
329
323
  * ```
330
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
331
324
  */
332
325
  some<TOutput extends TInput>(predicateFn: Predicate<TInput, ICollection<TInput>, TOutput>): boolean;
333
326
  /**
@@ -340,7 +333,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
340
333
  * collection.every(item => item < 6);
341
334
  * // true
342
335
  * ```
343
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
344
336
  */
345
337
  every<TOutput extends TInput>(predicateFn: Predicate<TInput, ICollection<TInput>, TOutput>): boolean;
346
338
  /**
@@ -675,7 +667,7 @@ export type ICollection<TInput> = Iterable<TInput> & {
675
667
  * // ]
676
668
  * ```
677
669
  */
678
- groupBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<RecordItem<TOutput, ICollection<TInput>>>;
670
+ groupBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<[TOutput, ICollection<TInput>]>;
679
671
  /**
680
672
  * The <i>countBy</i> method counts the occurrences of values in the collection by <i> selectFn </i>.
681
673
  * By default the equality check occurs on the item.
@@ -708,7 +700,7 @@ export type ICollection<TInput> = Iterable<TInput> & {
708
700
  * // ]
709
701
  * ```
710
702
  */
711
- countBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<RecordItem<TOutput, number>>;
703
+ countBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<[TOutput, number]>;
712
704
  /**
713
705
  * The <i>unique</i> method removes all duplicate values from the collection by <i> selectFn </i>.
714
706
  * By default the equality check occurs on the item.
@@ -1002,7 +994,7 @@ export type ICollection<TInput> = Iterable<TInput> & {
1002
994
  * // [["Chair", 100], ["Desk", 200]]
1003
995
  * ```
1004
996
  */
1005
- zip<TExtended>(iterable: Iterable<TExtended>): ICollection<RecordItem<TInput, TExtended>>;
997
+ zip<TExtended>(iterable: Iterable<TExtended>): ICollection<[TInput, TExtended]>;
1006
998
  /**
1007
999
  * The <i>sort</i> method sorts the collection. You can provide a <i>comparator</i> function.
1008
1000
  * @example
@@ -1076,7 +1068,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1076
1068
  * collection.first(item => item > 10);
1077
1069
  * // null
1078
1070
  * ```
1079
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1080
1071
  * // 3
1081
1072
  */
1082
1073
  first<TOutput extends TInput>(predicateFn?: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput | null;
@@ -1115,12 +1106,12 @@ export type ICollection<TInput> = Iterable<TInput> & {
1115
1106
  * collection.firstOr(() => -1, item => item > 10);
1116
1107
  * // -1
1117
1108
  * ```
1118
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1119
1109
  */
1120
1110
  firstOr<TOutput extends TInput, TExtended = TInput>(defaultValue: Lazyable<TExtended>, predicateFn?: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput | TExtended;
1121
1111
  /**
1122
1112
  * The <i>firstOrFail</i> method returns the first item in the collection that passes <i> predicateFn </i>.
1123
1113
  * By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than error is thrown.
1114
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1124
1115
  * @example
1125
1116
  * ```ts
1126
1117
  * import { ListCollection } from "@daiso-tech/core";;
@@ -1145,8 +1136,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1145
1136
  * collection.firstOrFail(item => item > 10);
1146
1137
  * // throws an error
1147
1138
  * ```
1148
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1149
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1150
1139
  */
1151
1140
  firstOrFail<TOutput extends TInput>(predicateFn?: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput;
1152
1141
  /**
@@ -1176,7 +1165,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1176
1165
  * collection.last(item => item > 10);
1177
1166
  * // null
1178
1167
  * ```
1179
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1180
1168
  * // 3
1181
1169
  */
1182
1170
  last<TOutput extends TInput>(predicateFn?: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput | null;
@@ -1215,12 +1203,12 @@ export type ICollection<TInput> = Iterable<TInput> & {
1215
1203
  * collection.lastOr(() => -1, item => item > 10);
1216
1204
  * // -1
1217
1205
  * ```
1218
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1219
1206
  */
1220
1207
  lastOr<TOutput extends TInput, TExtended = TInput>(defaultValue: Lazyable<TExtended>, predicateFn?: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput | TExtended;
1221
1208
  /**
1222
1209
  * The <i>lastOrFail</i> method returns the last item in the collection that passes <i> predicateFn </i>.
1223
1210
  * By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than error is thrown.
1211
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1224
1212
  * @example
1225
1213
  * ```ts
1226
1214
  * import { ListCollection } from "@daiso-tech/core";;
@@ -1245,8 +1233,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1245
1233
  * collection.lastOrFail(item => item > 10);
1246
1234
  * // throws an error
1247
1235
  * ```
1248
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1249
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1250
1236
  */
1251
1237
  lastOrFail<TOutput extends TInput>(predicateFn?: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput;
1252
1238
  /**
@@ -1268,7 +1254,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1268
1254
  * collection.before(item => item === 1);
1269
1255
  * // null
1270
1256
  * ```
1271
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1272
1257
  */
1273
1258
  before(predicateFn: Predicate<TInput, ICollection<TInput>>): TInput | null;
1274
1259
  /**
@@ -1298,12 +1283,12 @@ export type ICollection<TInput> = Iterable<TInput> & {
1298
1283
  * collection.beforeOr(() => -1, item => item === 1);
1299
1284
  * // -1
1300
1285
  * ```
1301
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1302
1286
  */
1303
1287
  beforeOr<TExtended = TInput>(defaultValue: Lazyable<TExtended>, predicateFn: Predicate<TInput, ICollection<TInput>>): TInput | TExtended;
1304
1288
  /**
1305
1289
  * The <i>beforeOrFail</i> method returns the item that comes before the first item that matches <i>predicateFn</i>.
1306
1290
  * If the collection is empty or the <i>predicateFn</i> does not match or matches the first item then an error is thrown.
1291
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1307
1292
  * @example
1308
1293
  * ```ts
1309
1294
  * import { ListCollection } from "@daiso-tech/core";;
@@ -1320,8 +1305,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1320
1305
  * collection.beforeOrFail(item => item === 1);
1321
1306
  * // error is thrown
1322
1307
  * ```
1323
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1324
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1325
1308
  */
1326
1309
  beforeOrFail(predicateFn: Predicate<TInput, ICollection<TInput>>): TInput;
1327
1310
  /**
@@ -1343,7 +1326,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1343
1326
  * collection.after(item => item === 4);
1344
1327
  * // null
1345
1328
  * ```
1346
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1347
1329
  */
1348
1330
  after(predicateFn: Predicate<TInput, ICollection<TInput>>): TInput | null;
1349
1331
  /**
@@ -1373,12 +1355,12 @@ export type ICollection<TInput> = Iterable<TInput> & {
1373
1355
  * collection.afterOr(() => -1, item => item === 4);
1374
1356
  * // -1
1375
1357
  * ```
1376
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1377
1358
  */
1378
1359
  afterOr<TExtended = TInput>(defaultValue: Lazyable<TExtended>, predicateFn: Predicate<TInput, ICollection<TInput>>): TInput | TExtended;
1379
1360
  /**
1380
1361
  * The <i>afterOrFail</i> method returns the item that comes after the first item that matches <i>predicateFn</i>.
1381
1362
  * If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then an error is thrown.
1363
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1382
1364
  * @example
1383
1365
  * ```ts
1384
1366
  * import { ListCollection } from "@daiso-tech/core";;
@@ -1395,13 +1377,13 @@ export type ICollection<TInput> = Iterable<TInput> & {
1395
1377
  * collection.afterOrFail(item => item === 4);
1396
1378
  * // error is thrown
1397
1379
  * ```
1398
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1399
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1400
1380
  */
1401
1381
  afterOrFail(predicateFn: Predicate<TInput, ICollection<TInput>>): TInput;
1402
1382
  /**
1403
1383
  * The <i>sole</i> method returns the first item in the collection that passes <i>predicateFn</i>, but only if <i>predicateFn</i> matches exactly one item.
1404
1384
  * If no items matches or multiple items are found an error will be thrown.
1385
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1386
+ * @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
1405
1387
  * @example
1406
1388
  * ```ts
1407
1389
  * import { ListCollection } from "@daiso-tech/core";;
@@ -1426,9 +1408,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1426
1408
  * collection.sole(item => item === 4);
1427
1409
  * // error is thrown
1428
1410
  * ```
1429
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1430
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1431
- * @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
1432
1411
  */
1433
1412
  sole<TOutput extends TInput>(predicateFn: Predicate<TInput, ICollection<TInput>, TOutput>): TOutput;
1434
1413
  /**
@@ -1453,22 +1432,18 @@ export type ICollection<TInput> = Iterable<TInput> & {
1453
1432
  * collection.count(value => value % 2 === 0);
1454
1433
  * // 3
1455
1434
  * ```
1456
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1457
1435
  */
1458
1436
  count(predicateFn: Predicate<TInput, ICollection<TInput>>): number;
1459
1437
  /**
1460
1438
  * The <i>size</i> returns the size of the collection.
1461
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1462
1439
  */
1463
1440
  size(): number;
1464
1441
  /**
1465
1442
  * The <i>isEmpty</i> returns true if the collection is empty.
1466
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1467
1443
  */
1468
1444
  isEmpty(): boolean;
1469
1445
  /**
1470
1446
  * The <i>isNotEmpty</i> returns true if the collection is not empty.
1471
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1472
1447
  */
1473
1448
  isNotEmpty(): boolean;
1474
1449
  /**
@@ -1481,7 +1456,6 @@ export type ICollection<TInput> = Iterable<TInput> & {
1481
1456
  * collection.searchFirst(item => item === "b");
1482
1457
  * // 1
1483
1458
  * ```
1484
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1485
1459
  */
1486
1460
  searchFirst(predicateFn: Predicate<TInput, ICollection<TInput>>): number;
1487
1461
  /**
@@ -1494,17 +1468,24 @@ export type ICollection<TInput> = Iterable<TInput> & {
1494
1468
  * collection.searchLast(item => item === "b");
1495
1469
  * // 2
1496
1470
  * ```
1497
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1498
1471
  */
1499
1472
  searchLast(predicateFn: Predicate<TInput, ICollection<TInput>>): number;
1500
1473
  /**
1501
1474
  * The <i>forEach</i> method iterates through all items in the collection.
1502
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1503
1475
  */
1504
1476
  forEach(callback: ForEach<TInput, ICollection<TInput>>): void;
1505
1477
  /**
1506
- * The <i>toArray</i> method converts the collection to a new array.
1507
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1478
+ * The <i>toArray</i> method converts the collection to a new <i>{@link Array}</i>.
1508
1479
  */
1509
1480
  toArray(): TInput[];
1481
+ /**
1482
+ * The <i>toRecord</i> method converts the collection to a new <i>{@link Record}</i>.
1483
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
1484
+ */
1485
+ toRecord(): EnsureRecord<TInput>;
1486
+ /**
1487
+ * The <i>toMap</i> method converts the collection to a new <i>{@link Map}</i>.
1488
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
1489
+ */
1490
+ toMap(): EnsureMap<TInput>;
1510
1491
  };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * @module Collection
3
+ */
4
+ /**
5
+ * @group Errors
6
+ */
7
+ export declare class CollectionError extends Error {
8
+ constructor(message: string, cause?: unknown);
9
+ }
10
+ /**
11
+ * @group Errors
12
+ */
13
+ export declare class UnexpectedCollectionError extends CollectionError {
14
+ constructor(message: string, cause?: unknown);
15
+ }
16
+ /**
17
+ * @group Errors
18
+ */
19
+ export declare class ItemNotFoundCollectionError extends CollectionError {
20
+ constructor(message: string, cause?: unknown);
21
+ }
22
+ /**
23
+ * @group Errors
24
+ */
25
+ export declare class MultipleItemsFoundCollectionError extends CollectionError {
26
+ constructor(message: string, cause?: unknown);
27
+ }
28
+ /**
29
+ * @group Errors
30
+ */
31
+ export declare class TypeCollectionError extends CollectionError {
32
+ constructor(message: string, cause?: unknown);
33
+ }
34
+ /**
35
+ * @group Errors
36
+ */
37
+ export declare class EmptyCollectionError extends CollectionError {
38
+ constructor(message: string, cause?: unknown);
39
+ }
@@ -2,13 +2,12 @@
2
2
  * @module Collection
3
3
  */
4
4
  import { type AsyncMap, type IAsyncCollection } from "../../../../collection/contracts/_module";
5
- import { type RecordItem } from "../../../../_shared/types";
6
5
  /**
7
6
  * @internal
8
7
  */
9
- export declare class AsyncCountByIterable<TInput, TOutput = TInput> implements AsyncIterable<RecordItem<TOutput, number>> {
8
+ export declare class AsyncCountByIterable<TInput, TOutput = TInput> implements AsyncIterable<[TOutput, number]> {
10
9
  private collection;
11
10
  private callback;
12
11
  constructor(collection: IAsyncCollection<TInput>, callback?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>);
13
- [Symbol.asyncIterator](): AsyncIterator<RecordItem<TOutput, number>>;
12
+ [Symbol.asyncIterator](): AsyncIterator<[TOutput, number]>;
14
13
  }
@@ -2,12 +2,11 @@
2
2
  * @module Collection
3
3
  */
4
4
  import { type AsyncIterableValue } from "../../../../_shared/types";
5
- import { type RecordItem } from "../../../../_shared/types";
6
5
  /**
7
6
  * @internal
8
7
  */
9
- export declare class AsyncEntriesIterable<TInput> implements AsyncIterable<RecordItem<number, TInput>> {
8
+ export declare class AsyncEntriesIterable<TInput> implements AsyncIterable<[number, TInput]> {
10
9
  private iterable;
11
10
  constructor(iterable: AsyncIterableValue<TInput>);
12
- [Symbol.asyncIterator](): AsyncIterator<RecordItem<number, TInput>>;
11
+ [Symbol.asyncIterator](): AsyncIterator<[number, TInput]>;
13
12
  }
@@ -2,14 +2,17 @@
2
2
  * @module Collection
3
3
  */
4
4
  import { type AsyncMap, type IAsyncCollection } from "../../../../collection/contracts/_module";
5
- import { type AsyncIterableValue, type RecordItem } from "../../../../_shared/types";
5
+ import { type AsyncIterableValue } from "../../../../_shared/types";
6
6
  /**
7
7
  * @internal
8
8
  */
9
- export declare class AsyncGroupByIterable<TInput, TOutput = TInput> implements AsyncIterable<RecordItem<TOutput, IAsyncCollection<TInput>>> {
9
+ export declare class AsyncGroupByIterable<TInput, TOutput = TInput> implements AsyncIterable<[TOutput, IAsyncCollection<TInput>]> {
10
10
  private collection;
11
11
  private selectFn;
12
12
  private makeCollection;
13
13
  constructor(collection: IAsyncCollection<TInput>, selectFn: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput> | undefined, makeCollection: <TInput>(iterable: AsyncIterableValue<TInput>) => IAsyncCollection<TInput>);
14
- [Symbol.asyncIterator](): AsyncIterator<RecordItem<TOutput, IAsyncCollection<TInput>>>;
14
+ [Symbol.asyncIterator](): AsyncIterator<[
15
+ TOutput,
16
+ IAsyncCollection<TInput>
17
+ ]>;
15
18
  }
@@ -5,7 +5,7 @@ import { type AsyncPredicate, type AsyncMap, type IAsyncCollection } from "../..
5
5
  /**
6
6
  * @internal
7
7
  */
8
- export declare class AsyncUpdateIterable<TInput, TFilterOutput extends TInput, TMapOutput> implements AsyncIterable<TInput | TFilterOutput | TMapOutput> {
8
+ export declare class AsyncChangeIterable<TInput, TFilterOutput extends TInput, TMapOutput> implements AsyncIterable<TInput | TFilterOutput | TMapOutput> {
9
9
  private collection;
10
10
  private predicateFn;
11
11
  private mapFn;
@@ -2,13 +2,12 @@
2
2
  * @module Collection
3
3
  */
4
4
  import { type AsyncIterableValue } from "../../../../_shared/types";
5
- import { type RecordItem } from "../../../../_shared/types";
6
5
  /**
7
6
  * @internal
8
7
  */
9
- export declare class AsyncZipIterable<TInput, TExtended> implements AsyncIterable<RecordItem<TInput, TExtended>> {
8
+ export declare class AsyncZipIterable<TInput, TExtended> implements AsyncIterable<[TInput, TExtended]> {
10
9
  private iterableA;
11
10
  private iterableB;
12
11
  constructor(iterableA: AsyncIterableValue<TInput>, iterableB: AsyncIterableValue<TExtended>);
13
- [Symbol.asyncIterator](): AsyncIterator<RecordItem<TInput, TExtended>>;
12
+ [Symbol.asyncIterator](): AsyncIterator<[TInput, TExtended]>;
14
13
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * @module Collection
3
3
  */
4
+ import type { EnsureMap, EnsureRecord } from "../../../collection/contracts/_module";
4
5
  import { type AsyncCollapse, type AsyncPredicate, type AsyncForEach, type AsyncMap, type AsyncModifier, type AsyncTap, type AsyncTransform, type Comparator, type IAsyncCollection, type AsyncReduce, type CrossJoinResult } from "../../../collection/contracts/_module";
5
6
  import { type AsyncIterableValue, type AsyncLazyable } from "../../../_shared/types";
6
- import { type RecordItem } from "../../../_shared/types";
7
7
  import type { TimeSpan } from "../../../utilities/_module";
8
8
  import { LazyPromise } from "../../../utilities/_module";
9
9
  /**
@@ -13,7 +13,7 @@ import { LazyPromise } from "../../../utilities/_module";
13
13
  * @group Adapters
14
14
  */
15
15
  export declare class AsyncIterableCollection<TInput> implements IAsyncCollection<TInput> {
16
- private iterable;
16
+ private readonly iterable;
17
17
  private static DEFAULT_CHUNK_SIZE;
18
18
  private static makeCollection;
19
19
  /**
@@ -22,7 +22,7 @@ export declare class AsyncIterableCollection<TInput> implements IAsyncCollection
22
22
  constructor(iterable?: AsyncIterableValue<TInput>);
23
23
  [Symbol.asyncIterator](): AsyncIterator<TInput>;
24
24
  toIterator(): AsyncIterator<TInput, void>;
25
- entries(): IAsyncCollection<RecordItem<number, TInput>>;
25
+ entries(): IAsyncCollection<[number, TInput]>;
26
26
  keys(): IAsyncCollection<number>;
27
27
  values(): IAsyncCollection<TInput>;
28
28
  filter<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TOutput>;
@@ -64,8 +64,8 @@ export declare class AsyncIterableCollection<TInput> implements IAsyncCollection
64
64
  split(chunkAmount: number): IAsyncCollection<IAsyncCollection<TInput>>;
65
65
  partition(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): IAsyncCollection<IAsyncCollection<TInput>>;
66
66
  sliding(chunkSize: number, step?: number): IAsyncCollection<IAsyncCollection<TInput>>;
67
- groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<RecordItem<TOutput, IAsyncCollection<TInput>>>;
68
- countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<RecordItem<TOutput, number>>;
67
+ groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, IAsyncCollection<TInput>]>;
68
+ countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, number]>;
69
69
  unique<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
70
70
  difference<TOutput = TInput>(iterable: AsyncIterableValue<TInput>, selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<TInput>;
71
71
  repeat(amount: number): IAsyncCollection<TInput>;
@@ -77,7 +77,7 @@ export declare class AsyncIterableCollection<TInput> implements IAsyncCollection
77
77
  insertBefore<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
78
78
  insertAfter<TExtended = TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>, iterable: AsyncIterableValue<TInput | TExtended>): IAsyncCollection<TInput | TExtended>;
79
79
  crossJoin<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<CrossJoinResult<TInput, TExtended>>;
80
- zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<RecordItem<TInput, TExtended>>;
80
+ zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<[TInput, TExtended]>;
81
81
  sort(comparator?: Comparator<TInput>): IAsyncCollection<TInput>;
82
82
  reverse(chunkSize?: number): IAsyncCollection<TInput>;
83
83
  shuffle(mathRandom?: () => number): IAsyncCollection<TInput>;
@@ -106,4 +106,6 @@ export declare class AsyncIterableCollection<TInput> implements IAsyncCollection
106
106
  searchLast(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
107
107
  forEach(callback: AsyncForEach<TInput, IAsyncCollection<TInput>>): LazyPromise<void>;
108
108
  toArray(): LazyPromise<TInput[]>;
109
+ toRecord(): LazyPromise<EnsureRecord<TInput>>;
110
+ toMap(): LazyPromise<EnsureMap<TInput>>;
109
111
  }
@@ -2,13 +2,12 @@
2
2
  * @module Collection
3
3
  */
4
4
  import { type ICollection, type Map } from "../../../../collection/contracts/_module";
5
- import { type RecordItem } from "../../../../_shared/types";
6
5
  /**
7
6
  * @internal
8
7
  */
9
- export declare class CountByIterable<TInput, TOutput = TInput> implements Iterable<RecordItem<TOutput, number>> {
8
+ export declare class CountByIterable<TInput, TOutput = TInput> implements Iterable<[TOutput, number]> {
10
9
  private collection;
11
10
  private selectFn;
12
11
  constructor(collection: ICollection<TInput>, selectFn?: Map<TInput, ICollection<TInput>, TOutput>);
13
- [Symbol.iterator](): Iterator<RecordItem<TOutput, number>>;
12
+ [Symbol.iterator](): Iterator<[TOutput, number]>;
14
13
  }
@@ -1,12 +1,11 @@
1
1
  /**
2
2
  * @module Collection
3
3
  */
4
- import { type RecordItem } from "../../../../_shared/types";
5
4
  /**
6
5
  * @internal
7
6
  */
8
- export declare class EntriesIterable<TInput> implements Iterable<RecordItem<number, TInput>> {
7
+ export declare class EntriesIterable<TInput> implements Iterable<[number, TInput]> {
9
8
  private iterable;
10
9
  constructor(iterable: Iterable<TInput>);
11
- [Symbol.iterator](): Iterator<RecordItem<number, TInput>>;
10
+ [Symbol.iterator](): Iterator<[number, TInput]>;
12
11
  }
@@ -2,14 +2,13 @@
2
2
  * @module Collection
3
3
  */
4
4
  import { type ICollection, type Map } from "../../../../collection/contracts/_module";
5
- import { type RecordItem } from "../../../../_shared/types";
6
5
  /**
7
6
  * @internal
8
7
  */
9
- export declare class GroupByIterable<TInput, TOutput = TInput> implements Iterable<RecordItem<TOutput, ICollection<TInput>>> {
8
+ export declare class GroupByIterable<TInput, TOutput = TInput> implements Iterable<[TOutput, ICollection<TInput>]> {
10
9
  private collection;
11
10
  private selectFn;
12
11
  private makeCollection;
13
12
  constructor(collection: ICollection<TInput>, selectFn: Map<TInput, ICollection<TInput>, TOutput> | undefined, makeCollection: <TInput>(iterable: Iterable<TInput>) => ICollection<TInput>);
14
- [Symbol.iterator](): Iterator<RecordItem<TOutput, ICollection<TInput>>>;
13
+ [Symbol.iterator](): Iterator<[TOutput, ICollection<TInput>]>;
15
14
  }
@@ -5,7 +5,7 @@ import { type Predicate, type ICollection, type Map } from "../../../../collecti
5
5
  /**
6
6
  * @internal
7
7
  */
8
- export declare class UpdateIterable<TInput, TFilterOutput extends TInput, TMapOutput> implements Iterable<TInput | TFilterOutput | TMapOutput> {
8
+ export declare class ChangeIterable<TInput, TFilterOutput extends TInput, TMapOutput> implements Iterable<TInput | TFilterOutput | TMapOutput> {
9
9
  private collection;
10
10
  private predicateFn;
11
11
  private mapFn;
@@ -1,13 +1,12 @@
1
1
  /**
2
2
  * @module Collection
3
3
  */
4
- import { type RecordItem } from "../../../../_shared/types";
5
4
  /**
6
5
  * @internal
7
6
  */
8
- export declare class ZipIterable<TInput, TExtended> implements Iterable<RecordItem<TInput, TExtended>> {
7
+ export declare class ZipIterable<TInput, TExtended> implements Iterable<[TInput, TExtended]> {
9
8
  private iterableA;
10
9
  private iterableB;
11
10
  constructor(iterableA: Iterable<TInput>, iterableB: Iterable<TExtended>);
12
- [Symbol.iterator](): Iterator<RecordItem<TInput, TExtended>>;
11
+ [Symbol.iterator](): Iterator<[TInput, TExtended]>;
13
12
  }