@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,42 +1,6 @@
1
1
  /**
2
2
  * @module Collection
3
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
- }
40
4
  export type Comparator<TItem> = (itemA: TItem, itemB: TItem) => number;
41
5
  export type Predicate_<TInput, TCollection> = (item: TInput, index: number, collection: TCollection) => boolean;
42
6
  export type PredicateGuard<TInput, TCollection, TOutput extends TInput = TInput> = (item: TInput, index: number, collection: TCollection) => item is TOutput;
@@ -65,3 +29,5 @@ export type CrossJoinResult<TInput, TExtended> = TInput extends [
65
29
  infer R,
66
30
  ...infer L
67
31
  ] ? [R, ...L, TExtended] : [TInput, TExtended];
32
+ export type EnsureRecord<TInput> = TInput extends [infer TKey, infer TValue] | readonly [infer TKey, infer TValue] ? TKey extends string | number | symbol ? Record<TKey, TValue> : never : never;
33
+ export type EnsureMap<TInput> = TInput extends [infer TKey, infer TValue] | readonly [infer TKey, infer TValue] ? globalThis.Map<TKey, TValue> : never;
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * @module Collection
3
3
  */
4
- import type { AsyncReduce, CrossJoinResult, AsyncPredicate, AsyncForEach, AsyncMap, AsyncModifier, AsyncTap, AsyncTransform, Comparator } from "../../collection/contracts/_shared";
5
- import type { RecordItem, AsyncLazyable, AsyncIterableValue } from "../../_shared/types";
4
+ import type { AsyncReduce, CrossJoinResult, AsyncPredicate, AsyncForEach, AsyncMap, AsyncModifier, AsyncTap, AsyncTransform, Comparator, EnsureRecord, EnsureMap } from "../../collection/contracts/_module";
5
+ import type { AsyncLazyable, AsyncIterableValue } from "../../_shared/types";
6
6
  import type { LazyPromise, TimeSpan } from "../../utilities/_module";
7
7
  export type AsyncCollapse<TValue> = TValue extends Array<infer TItem> | Iterable<infer TItem> | IAsyncCollection<infer TItem> ? TItem : TValue;
8
8
  /**
9
9
  * The <i>IAsyncCollection</i> contract offers a fluent and efficient approach to working with {@link AsyncIterable} objects.
10
10
  * <i>IAsyncCollection</i> is immutable.
11
11
  * @group Contracts
12
+ * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
12
13
  */
13
14
  export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
14
15
  /**
@@ -18,7 +19,7 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
18
19
  /**
19
20
  * The <i>entries</i> returns an IAsyncCollection of key, value pairs for every entry in the collection.
20
21
  */
21
- entries(): IAsyncCollection<RecordItem<number, TInput>>;
22
+ entries(): IAsyncCollection<[number, TInput]>;
22
23
  /**
23
24
  * The <i>keys</i> method returns an IAsyncCollection of keys in the collection.
24
25
  */
@@ -195,7 +196,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
195
196
  get(index: number): LazyPromise<TInput | null>;
196
197
  /**
197
198
  * The <i>getOrFail</i> method returns the item by index. If the item is not found an error will be thrown.
198
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
199
199
  * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
200
200
  * @example
201
201
  * ```ts
@@ -225,6 +225,8 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
225
225
  page(page: number, pageSize: number): IAsyncCollection<TInput>;
226
226
  /**
227
227
  * 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.
228
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
229
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
228
230
  * @example
229
231
  * ```ts
230
232
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -233,13 +235,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
233
235
  * await 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(): LazyPromise<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.
242
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
243
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
243
244
  * @example
244
245
  * ```ts
245
246
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -248,13 +249,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
248
249
  * await collection.average();
249
250
  * // 2
250
251
  * ```
251
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
252
- * @throws {TypeCollectionError} {@link TypeCollectionError}
253
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
254
252
  */
255
253
  average(): LazyPromise<Extract<TInput, number>>;
256
254
  /**
257
255
  * 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.
256
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
257
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
258
258
  * @example
259
259
  * ```ts
260
260
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -263,13 +263,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
263
263
  * await collection.median();
264
264
  * // 2
265
265
  * ```
266
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
267
- * @throws {TypeCollectionError} {@link TypeCollectionError}
268
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
269
266
  */
270
267
  median(): LazyPromise<Extract<TInput, number>>;
271
268
  /**
272
269
  * 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.
270
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
271
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
273
272
  * @example
274
273
  * ```ts
275
274
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -278,13 +277,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
278
277
  * await collection.min();
279
278
  * // 1
280
279
  * ```
281
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
282
- * @throws {TypeCollectionError} {@link TypeCollectionError}
283
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
284
280
  */
285
281
  min(): LazyPromise<Extract<TInput, number>>;
286
282
  /**
287
283
  * 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.
284
+ * @throws {TypeCollectionError} {@link TypeCollectionError}
285
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
288
286
  * @example
289
287
  * ```ts
290
288
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -293,13 +291,11 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
293
291
  * await collection.max();
294
292
  * // 3
295
293
  * ```
296
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
297
- * @throws {TypeCollectionError} {@link TypeCollectionError}
298
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
299
294
  */
300
295
  max(): LazyPromise<Extract<TInput, number>>;
301
296
  /**
302
297
  * The <i>percentage</i> method may be used to quickly determine the percentage of items in the collection that pass <i>predicateFn</i>.
298
+ * @throws {EmptyCollectionError} {@link EmptyCollectionError}
303
299
  * @example
304
300
  * ```ts
305
301
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -308,8 +304,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
308
304
  * await collection.percentage(value => value === 1);
309
305
  * // 33.333
310
306
  * ```
311
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
312
- * @throws {EmptyCollectionError} {@link EmptyCollectionError}
313
307
  */
314
308
  percentage(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
315
309
  /**
@@ -322,7 +316,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
322
316
  * await collection.some(item => item === 1);
323
317
  * // true
324
318
  * ```
325
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
326
319
  */
327
320
  some<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<boolean>;
328
321
  /**
@@ -335,7 +328,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
335
328
  * await collection.every(item => item < 6);
336
329
  * // true
337
330
  * ```
338
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
339
331
  */
340
332
  every<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<boolean>;
341
333
  /**
@@ -669,7 +661,7 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
669
661
  * // ]
670
662
  * ```
671
663
  */
672
- groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<RecordItem<TOutput, IAsyncCollection<TInput>>>;
664
+ groupBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, IAsyncCollection<TInput>]>;
673
665
  /**
674
666
  * The <i>countBy</i> method counts the occurrences of values in the collection by <i> selectFn </i>.
675
667
  * By default the equality check occurs on the item.
@@ -702,7 +694,7 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
702
694
  * // ]
703
695
  * ```
704
696
  */
705
- countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<RecordItem<TOutput, number>>;
697
+ countBy<TOutput = TInput>(selectFn?: AsyncMap<TInput, IAsyncCollection<TInput>, TOutput>): IAsyncCollection<[TOutput, number]>;
706
698
  /**
707
699
  * The <i>unique</i> method removes all duplicate values from the collection by <i> selectFn </i>.
708
700
  * By default the equality check occurs on the item.
@@ -996,7 +988,7 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
996
988
  * // [["Chair", 100], ["Desk", 200]]
997
989
  * ```
998
990
  */
999
- zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<RecordItem<TInput, TExtended>>;
991
+ zip<TExtended>(iterable: AsyncIterableValue<TExtended>): IAsyncCollection<[TInput, TExtended]>;
1000
992
  /**
1001
993
  * The <i>sort</i> method sorts the collection. You can provide a <i>comparator</i> function.
1002
994
  * @example
@@ -1071,7 +1063,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1071
1063
  * await collection.first(item => item > 10);
1072
1064
  * // null
1073
1065
  * ```
1074
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1075
1066
  * // 3
1076
1067
  */
1077
1068
  first<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | null>;
@@ -1110,12 +1101,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1110
1101
  * await collection.firstOr(() => -1, item => item > 10);
1111
1102
  * // -1
1112
1103
  * ```
1113
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1114
1104
  */
1115
1105
  firstOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | TExtended>;
1116
1106
  /**
1117
1107
  * The <i>firstOrFail</i> method returns the first item in the collection that passes <i> predicateFn </i>.
1118
1108
  * By default it will get the first item. If the collection is empty or no items passes <i> predicateFn </i> than error is thrown.
1109
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1119
1110
  * @example
1120
1111
  * ```ts
1121
1112
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -1123,16 +1114,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1123
1114
  * const collection = new AsyncIterableCollection([1, 2, 3, 4]);
1124
1115
  * await collection.firstOrFail();
1125
1116
  * // 1
1126
- * @example
1127
1117
  * ```
1118
+ * @example
1128
1119
  * ```ts
1129
1120
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
1130
1121
  *
1131
1122
  * const collection = new AsyncIterableCollection([1, 2, 3, 4]);
1132
1123
  * await collection.firstOrFail(item => item > 2);
1133
1124
  * // 3
1134
- * @example
1135
1125
  * ```
1126
+ * @example
1136
1127
  * ```ts
1137
1128
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
1138
1129
  *
@@ -1140,8 +1131,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1140
1131
  * await collection.firstOrFail(item => item > 10);
1141
1132
  * // throws an error
1142
1133
  * ```
1143
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1144
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1145
1134
  */
1146
1135
  firstOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
1147
1136
  /**
@@ -1171,7 +1160,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1171
1160
  * await collection.last(item => item > 10);
1172
1161
  * // null
1173
1162
  * ```
1174
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1175
1163
  * // 3
1176
1164
  */
1177
1165
  last<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | null>;
@@ -1210,12 +1198,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1210
1198
  * await collection.lastOr(() => -1, item => item > 10);
1211
1199
  * // -1
1212
1200
  * ```
1213
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1214
1201
  */
1215
1202
  lastOr<TOutput extends TInput, TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput | TExtended>;
1216
1203
  /**
1217
1204
  * The <i>lastOrFail</i> method returns the last item in the collection that passes <i> predicateFn </i>.
1218
1205
  * By default it will get the last item. If the collection is empty or no items passes <i> predicateFn </i> than error is thrown.
1206
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1219
1207
  * @example
1220
1208
  * ```ts
1221
1209
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -1240,8 +1228,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1240
1228
  * await collection.lastOrFail(item => item > 10);
1241
1229
  * // throws an error
1242
1230
  * ```
1243
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1244
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1245
1231
  */
1246
1232
  lastOrFail<TOutput extends TInput>(predicateFn?: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
1247
1233
  /**
@@ -1263,7 +1249,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1263
1249
  * await collection.before(item => item === 1);
1264
1250
  * // null
1265
1251
  * ```
1266
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1267
1252
  */
1268
1253
  before(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | null>;
1269
1254
  /**
@@ -1293,12 +1278,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1293
1278
  * await collection.beforeOr(() => -1, item => item === 1);
1294
1279
  * // -1
1295
1280
  * ```
1296
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1297
1281
  */
1298
1282
  beforeOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | TExtended>;
1299
1283
  /**
1300
1284
  * The <i>beforeOrFail</i> method returns the item that comes before the first item that matches <i>predicateFn</i>.
1301
1285
  * If the collection is empty or the <i>predicateFn</i> does not match or matches the first item then an error is thrown.
1286
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1302
1287
  * @example
1303
1288
  * ```ts
1304
1289
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -1315,8 +1300,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1315
1300
  * await collection.beforeOrFail(item => item === 1);
1316
1301
  * // error is thrown
1317
1302
  * ```
1318
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1319
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1320
1303
  */
1321
1304
  beforeOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput>;
1322
1305
  /**
@@ -1338,7 +1321,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1338
1321
  * await collection.after(item => item === 4);
1339
1322
  * // null
1340
1323
  * ```
1341
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1342
1324
  */
1343
1325
  after(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | null>;
1344
1326
  /**
@@ -1359,8 +1341,8 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1359
1341
  * const collection = new AsyncIterableCollection([1, 2, 3, 4]);
1360
1342
  * await collection.afterOr(-1, item => item === 4);
1361
1343
  * // -1
1362
- * @example
1363
1344
  * ```
1345
+ * @example
1364
1346
  * ```ts
1365
1347
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
1366
1348
  *
@@ -1368,12 +1350,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1368
1350
  * await collection.afterOr(() => -1, item => item === 4);
1369
1351
  * // -1
1370
1352
  * ```
1371
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1372
1353
  */
1373
1354
  afterOr<TExtended = TInput>(defaultValue: AsyncLazyable<TExtended>, predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput | TExtended>;
1374
1355
  /**
1375
1356
  * The <i>afterOrFail</i> method returns the item that comes after the first item that matches <i>predicateFn</i>.
1376
1357
  * If the collection is empty or the <i>predicateFn</i> does not match or matches the last item then an error is thrown.
1358
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1377
1359
  * @example
1378
1360
  * ```ts
1379
1361
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -1390,13 +1372,13 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1390
1372
  * await collection.afterOrFail(item => item === 4);
1391
1373
  * // error is thrown
1392
1374
  * ```
1393
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1394
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1395
1375
  */
1396
1376
  afterOrFail(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<TInput>;
1397
1377
  /**
1398
1378
  * 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.
1399
1379
  * If no items matches or multiple items are found an error will be thrown.
1380
+ * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1381
+ * @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
1400
1382
  * @example
1401
1383
  * ```ts
1402
1384
  * import { AsyncIterableCollection } from "@daiso-tech/core";;
@@ -1421,9 +1403,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1421
1403
  * await collection.sole(item => item === 4);
1422
1404
  * // error is thrown
1423
1405
  * ```
1424
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1425
- * @throws {ItemNotFoundCollectionError} {@link ItemNotFoundCollectionError}
1426
- * @throws {MultipleItemsFoundCollectionError} {@link MultipleItemsFoundCollectionError}
1427
1406
  */
1428
1407
  sole<TOutput extends TInput>(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>, TOutput>): LazyPromise<TOutput>;
1429
1408
  /**
@@ -1448,22 +1427,18 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1448
1427
  * await collection.count(value => value % 2 === 0);
1449
1428
  * // 3
1450
1429
  * ```
1451
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1452
1430
  */
1453
1431
  count(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
1454
1432
  /**
1455
1433
  * The <i>size</i> returns the size of the collection.
1456
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1457
1434
  */
1458
1435
  size(): LazyPromise<number>;
1459
1436
  /**
1460
1437
  * The <i>isEmpty</i> returns true if the collection is empty.
1461
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1462
1438
  */
1463
1439
  isEmpty(): LazyPromise<boolean>;
1464
1440
  /**
1465
1441
  * The <i>isNotEmpty</i> returns true if the collection is not empty.
1466
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1467
1442
  */
1468
1443
  isNotEmpty(): LazyPromise<boolean>;
1469
1444
  /**
@@ -1476,7 +1451,6 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1476
1451
  * await collection.searchFirst(item => item === "b");
1477
1452
  * // 1
1478
1453
  * ```
1479
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1480
1454
  */
1481
1455
  searchFirst(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
1482
1456
  /**
@@ -1489,19 +1463,12 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1489
1463
  * await collection.searchLast(item => item === "b");
1490
1464
  * // 2
1491
1465
  * ```
1492
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1493
1466
  */
1494
1467
  searchLast(predicateFn: AsyncPredicate<TInput, IAsyncCollection<TInput>>): LazyPromise<number>;
1495
1468
  /**
1496
1469
  * The <i>forEach</i> method iterates through all items in the collection.
1497
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1498
1470
  */
1499
1471
  forEach(callback: AsyncForEach<TInput, IAsyncCollection<TInput>>): LazyPromise<void>;
1500
- /**
1501
- * The <i>toArray</i> method converts the collection to a new array.
1502
- * @throws {UnexpectedCollectionError} {@link UnexpectedCollectionError}
1503
- */
1504
- toArray(): LazyPromise<TInput[]>;
1505
1472
  /**
1506
1473
  * The <i>delay</i> method will add delay between each iteration.
1507
1474
  * This method is especially useful for situations where you may be interacting with external APIs that rate limit incoming requests:
@@ -1553,4 +1520,16 @@ export type IAsyncCollection<TInput> = AsyncIterable<TInput> & {
1553
1520
  * ```
1554
1521
  */
1555
1522
  takeUntilTimeout(timeInMs: TimeSpan, shouldThrow?: boolean): IAsyncCollection<TInput>;
1523
+ /**
1524
+ * The <i>toArray</i> method converts the collection to a new <i>{@link Array}</i>.
1525
+ */
1526
+ toArray(): LazyPromise<TInput[]>;
1527
+ /**
1528
+ * The <i>toRecord</i> method converts the collection to a new <i>{@link Record}</i>.
1529
+ */
1530
+ toRecord(): LazyPromise<EnsureRecord<TInput>>;
1531
+ /**
1532
+ * The <i>toMap</i> method converts the collection to a new <i>{@link Map}</i>.
1533
+ */
1534
+ toMap(): LazyPromise<EnsureMap<TInput>>;
1556
1535
  };