@typedly/data-traits 1.1.0 → 2.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typedly/data-traits",
3
- "version": "1.1.0",
3
+ "version": "2.0.0",
4
4
  "author": "wwwdev.io <dev@wwwdev.io>",
5
5
  "description": "A TypeScript type definitions package for configurable data traits, providing various kinds of configurable data interfaces.",
6
6
  "license": "MIT",
@@ -100,6 +100,25 @@ interface Cloneable<O, R extends boolean = false> {
100
100
  cloneWith?(options: O): AsyncReturn<R, this>;
101
101
  }
102
102
 
103
+ /**
104
+ * @description Capability for objects that can be traversed/iterated.
105
+ * @export
106
+ * @interface Traversable
107
+ * @template E The element type
108
+ */
109
+ interface Traversable<E> {
110
+ /**
111
+ * @description Synchronous iterator
112
+ * @returns {IterableIterator<E>}
113
+ */
114
+ [Symbol.iterator](): IterableIterator<E>;
115
+ /**
116
+ * @description Asynchronous iterator
117
+ * @returns {AsyncIterableIterator<E>}
118
+ */
119
+ [Symbol.asyncIterator]?(): AsyncIterableIterator<E>;
120
+ }
121
+
103
122
  /**
104
123
  * @description Trait for collection-like data types that can hold multiple items and provide methods for adding, deleting, and iterating over those items.
105
124
  * @export
@@ -107,7 +126,7 @@ interface Cloneable<O, R extends boolean = false> {
107
126
  * @template E Element type contained in the collection.
108
127
  * @template {boolean} [R=false] whether the methods return a `Promise` or not.
109
128
  */
110
- interface Collection<E, R extends boolean = false> extends Iterable<E>, AsyncIterable<E> {
129
+ interface Collection<E, R extends boolean = false> extends Traversable<E> {
111
130
  /**
112
131
  * @description The number of items in the collection.
113
132
  * @returns {number}
@@ -129,7 +148,7 @@ interface Collection<E, R extends boolean = false> extends Iterable<E>, AsyncIte
129
148
  * @description Executes a provided function once for each collection element.
130
149
  * @param {(element: E, collection: Collection<E, R>) => void} callbackfn Function to execute for each element.
131
150
  * @param {?*} [thisArg] Value to use as `this` when executing `callbackfn`.
132
- * @returns {AsyncReturn<R, this>}
151
+ * @returns {AsyncReturn<R, this>} The collection instance `this`, or in `Promise`.
133
152
  */
134
153
  forEach(callbackfn: (element: E, collection: Collection<E, R>) => void, thisArg?: any): AsyncReturn<R, this>;
135
154
  /**
@@ -689,25 +708,6 @@ interface Transformable<T, R extends boolean = false> {
689
708
  map<U>(fn: (value: T) => U): AsyncReturn<R, U>;
690
709
  }
691
710
 
692
- /**
693
- * @description Capability for objects that can be traversed/iterated.
694
- * @export
695
- * @interface Traversable
696
- * @template E The element type
697
- */
698
- interface Traversable<E> {
699
- /**
700
- * @description Synchronous iterator
701
- * @returns {IterableIterator<E>}
702
- */
703
- [Symbol.iterator](): IterableIterator<E>;
704
- /**
705
- * @description Asynchronous iterator
706
- * @returns {AsyncIterableIterator<E>}
707
- */
708
- [Symbol.asyncIterator]?(): AsyncIterableIterator<E>;
709
- }
710
-
711
711
  /**
712
712
  * @description Interface for data types that can be validated with custom rules and track validation errors.
713
713
  * @export