@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,16 +1,16 @@
1
1
  /**
2
2
  * @module Collection
3
3
  */
4
+ import type { EnsureMap, EnsureRecord } from "../../../collection/contracts/_module";
4
5
  import { type Collapse, type Comparator, type Predicate, type ForEach, type ICollection, type Map, type Modifier, type Tap, type Transform, type Reduce, type CrossJoinResult } from "../../../collection/contracts/_module";
5
6
  import { type Lazyable } from "../../../_shared/types";
6
- import { type RecordItem } from "../../../_shared/types";
7
7
  /**
8
8
  * All methods that return <i>{@link ICollection}</i> are executed lazly which means they will be executed when the <i>IterableCollection</i> is iterated with <i>forEach</i> method or "for of" loop.
9
9
  * The rest of the methods are executed eagerly.
10
10
  * @group Adapters
11
11
  */
12
12
  export declare class IterableCollection<TInput> implements ICollection<TInput> {
13
- private iterable;
13
+ private readonly iterable;
14
14
  private static DEFAULT_CHUNK_SIZE;
15
15
  private static makeCollection;
16
16
  /**
@@ -19,7 +19,7 @@ export declare class IterableCollection<TInput> implements ICollection<TInput> {
19
19
  constructor(iterable: Iterable<TInput>);
20
20
  [Symbol.iterator](): Iterator<TInput>;
21
21
  toIterator(): Iterator<TInput, void>;
22
- entries(): ICollection<RecordItem<number, TInput>>;
22
+ entries(): ICollection<[number, TInput]>;
23
23
  keys(): ICollection<number>;
24
24
  values(): ICollection<TInput>;
25
25
  filter<TOutput extends TInput>(predicateFn: Predicate<TInput, ICollection<TInput>, TOutput>): ICollection<TOutput>;
@@ -61,8 +61,8 @@ export declare class IterableCollection<TInput> implements ICollection<TInput> {
61
61
  split(chunkAmount: number): ICollection<ICollection<TInput>>;
62
62
  partition(predicateFn: Predicate<TInput, ICollection<TInput>>): ICollection<ICollection<TInput>>;
63
63
  sliding(chunkSize: number, step?: number): ICollection<ICollection<TInput>>;
64
- groupBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<RecordItem<TOutput, ICollection<TInput>>>;
65
- countBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<RecordItem<TOutput, number>>;
64
+ groupBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<[TOutput, ICollection<TInput>]>;
65
+ countBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<[TOutput, number]>;
66
66
  unique<TOutput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<TInput>;
67
67
  difference<TOutput = TInput>(iterable: Iterable<TInput>, mapFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<TInput>;
68
68
  repeat(amount: number): ICollection<TInput>;
@@ -74,7 +74,7 @@ export declare class IterableCollection<TInput> implements ICollection<TInput> {
74
74
  insertBefore<TExtended = TInput>(predicateFn: Predicate<TInput, ICollection<TInput>>, iterable: Iterable<TInput | TExtended>): ICollection<TInput | TExtended>;
75
75
  insertAfter<TExtended = TInput>(predicateFn: Predicate<TInput, ICollection<TInput>>, iterable: Iterable<TInput | TExtended>): ICollection<TInput | TExtended>;
76
76
  crossJoin<TExtended>(iterable: Iterable<TExtended>): ICollection<CrossJoinResult<TInput, TExtended>>;
77
- zip<TExtended>(iterable: Iterable<TExtended>): ICollection<RecordItem<TInput, TExtended>>;
77
+ zip<TExtended>(iterable: Iterable<TExtended>): ICollection<[TInput, TExtended]>;
78
78
  sort(comparator?: Comparator<TInput>): ICollection<TInput>;
79
79
  reverse(chunkSize?: number): ICollection<TInput>;
80
80
  shuffle(mathRandom?: () => number): ICollection<TInput>;
@@ -100,4 +100,6 @@ export declare class IterableCollection<TInput> implements ICollection<TInput> {
100
100
  searchLast(predicateFn: Predicate<TInput, ICollection<TInput>>): number;
101
101
  forEach(callback: ForEach<TInput, ICollection<TInput>>): void;
102
102
  toArray(): TInput[];
103
+ toRecord(): EnsureRecord<TInput>;
104
+ toMap(): EnsureMap<TInput>;
103
105
  }
@@ -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 Collapse, type Comparator, type Predicate, type ICollection, type Map, type Modifier, type Tap, type Transform, type Reduce, type ForEach, type CrossJoinResult } from "../../../collection/contracts/_module";
5
6
  import { type Lazyable } from "../../../_shared/types";
6
- import { type RecordItem } from "../../../_shared/types";
7
7
  /**
8
8
  * All methods in <i>ListCollection</i> are executed eagerly.
9
9
  * @group Adapters
@@ -16,7 +16,7 @@ export declare class ListCollection<TInput> implements ICollection<TInput> {
16
16
  constructor(iterable?: Iterable<TInput>);
17
17
  [Symbol.iterator](): Iterator<TInput>;
18
18
  toIterator(): Iterator<TInput, void>;
19
- entries(): ICollection<RecordItem<number, TInput>>;
19
+ entries(): ICollection<[number, TInput]>;
20
20
  keys(): ICollection<number>;
21
21
  values(): ICollection<TInput>;
22
22
  filter<TOutput extends TInput>(predicateFn: Predicate<TInput, ICollection<TInput>, TOutput>): ICollection<TOutput>;
@@ -58,8 +58,8 @@ export declare class ListCollection<TInput> implements ICollection<TInput> {
58
58
  split(chunkAmount: number): ICollection<ICollection<TInput>>;
59
59
  partition(predicateFn: Predicate<TInput, ICollection<TInput>>): ICollection<ICollection<TInput>>;
60
60
  sliding(chunkSize: number, step?: number): ICollection<ICollection<TInput>>;
61
- groupBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<RecordItem<TOutput, ICollection<TInput>>>;
62
- countBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<RecordItem<TOutput, number>>;
61
+ groupBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<[TOutput, ICollection<TInput>]>;
62
+ countBy<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<[TOutput, number]>;
63
63
  unique<TOutput = TInput>(selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<TInput>;
64
64
  difference<TOutput = TInput>(iterable: Iterable<TInput>, selectFn?: Map<TInput, ICollection<TInput>, TOutput>): ICollection<TInput>;
65
65
  repeat(amount: number): ICollection<TInput>;
@@ -71,7 +71,7 @@ export declare class ListCollection<TInput> implements ICollection<TInput> {
71
71
  insertBefore<TExtended = TInput>(predicateFn: Predicate<TInput, ICollection<TInput>>, iterable: Iterable<TInput | TExtended>): ICollection<TInput | TExtended>;
72
72
  insertAfter<TExtended = TInput>(predicateFn: Predicate<TInput, ICollection<TInput>>, iterable: Iterable<TInput | TExtended>): ICollection<TInput | TExtended>;
73
73
  crossJoin<TExtended>(iterable: Iterable<TExtended>): ICollection<CrossJoinResult<TInput, TExtended>>;
74
- zip<TExtended>(iterable: Iterable<TExtended>): ICollection<RecordItem<TInput, TExtended>>;
74
+ zip<TExtended>(iterable: Iterable<TExtended>): ICollection<[TInput, TExtended]>;
75
75
  sort(comparator?: Comparator<TInput>): ICollection<TInput>;
76
76
  reverse(_chunkSize?: number): ICollection<TInput>;
77
77
  shuffle(mathRandom?: () => number): ICollection<TInput>;
@@ -97,4 +97,6 @@ export declare class ListCollection<TInput> implements ICollection<TInput> {
97
97
  searchLast(predicateFn: Predicate<TInput, ICollection<TInput>>): number;
98
98
  forEach(callback: ForEach<TInput, ICollection<TInput>>): void;
99
99
  toArray(): TInput[];
100
+ toRecord(): EnsureRecord<TInput>;
101
+ toMap(): EnsureMap<TInput>;
100
102
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@daiso-tech/core",
3
3
  "private": false,
4
- "version": "0.12.0",
4
+ "version": "0.13.0",
5
5
  "author": "Yousif Abdulkarim",
6
6
  "license": "Apache-2.0",
7
7
  "main": "./dist/cjs/_module.js",