@typedly/data-traits 1.0.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/README.md +13 -0
- package/package.json +1 -1
- package/types/typedly-data-traits.d.ts +22 -3
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ A **TypeScript** type definitions package for configurable data traits, providin
|
|
|
51
51
|
- **Serializable**: Serialize and deserialize data values with async support
|
|
52
52
|
- **Timestamped**: Automatic tracking of creation, modification, and access times
|
|
53
53
|
- **Transformable**: Transform values with `map` and `flatMap` operations
|
|
54
|
+
- **Traversable**: Adds required iterable iterator, and optional async iterable iterator
|
|
54
55
|
- **Validatable**: Comprehensive validation system with custom validators and error reporting
|
|
55
56
|
- **Versionable**: Version control with history tracking, snapshots, and rollback support
|
|
56
57
|
|
|
@@ -85,6 +86,7 @@ A **TypeScript** type definitions package for configurable data traits, providin
|
|
|
85
86
|
- [`Serializable`](#serializable)
|
|
86
87
|
- [`Timestamped`](#timestamped)
|
|
87
88
|
- [`Transformable`](#transformable)
|
|
89
|
+
- [`Traversable`](#traversable)
|
|
88
90
|
- [`Validatable`](#validatable)
|
|
89
91
|
- [`Versionable`](#versionable)
|
|
90
92
|
- [Contributing](#contributing)
|
|
@@ -140,6 +142,7 @@ import {
|
|
|
140
142
|
Serializable,
|
|
141
143
|
Timestamped,
|
|
142
144
|
Transformable,
|
|
145
|
+
Traversable,
|
|
143
146
|
Validatable,
|
|
144
147
|
Versionable,
|
|
145
148
|
} from '@typedly/data-traits';
|
|
@@ -397,6 +400,16 @@ import { Transformable } from '@typedly/data-traits';
|
|
|
397
400
|
|
|
398
401
|
[Source](https://github.com/typedly/data-traits/blob/main/src/lib/transformable.trait.ts)
|
|
399
402
|
|
|
403
|
+
### `Traversable`
|
|
404
|
+
|
|
405
|
+
Capability for objects that can be traversed/iterated.
|
|
406
|
+
|
|
407
|
+
```typescript
|
|
408
|
+
import { Traversable } from '@typedly/data-traits';
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
[Source](https://github.com/typedly/data-traits/blob/main/src/lib/traversable.trait.ts)
|
|
412
|
+
|
|
400
413
|
### `Validatable`
|
|
401
414
|
|
|
402
415
|
Interface for data types that can be validated with custom rules and track validation errors.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typedly/data-traits",
|
|
3
|
-
"version": "
|
|
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
|
|
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
|
/**
|
|
@@ -757,4 +776,4 @@ interface Versionable<T, V = unknown, R extends boolean = false> extends Reverti
|
|
|
757
776
|
snapshot(): AsyncReturn<R, T>;
|
|
758
777
|
}
|
|
759
778
|
|
|
760
|
-
export type { Adaptable, Cacheable, Cleanable, Cloneable, Collection, Comparable, Compressible, Configurable, Encryptable, Exportable, Freezable, Identifiable, Indexable, Measurable, Mergeable, Observable, Paginated, Persistable, Printable, Queryable, Resettable, Revertible, Serializable, Timestamped, Transformable, Validatable, Versionable };
|
|
779
|
+
export type { Adaptable, Cacheable, Cleanable, Cloneable, Collection, Comparable, Compressible, Configurable, Encryptable, Exportable, Freezable, Identifiable, Indexable, Measurable, Mergeable, Observable, Paginated, Persistable, Printable, Queryable, Resettable, Revertible, Serializable, Timestamped, Transformable, Traversable, Validatable, Versionable };
|