@typedly/collection 1.0.1 → 1.1.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 +11 -0
- package/package.json +1 -1
- package/types/typedly-collection.d.ts +13 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ A **TypeScript** type definitions package for data collections with customizable
|
|
|
16
16
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
|
+
- **Adapter**: The default interface for adapters in collections.
|
|
19
20
|
- **Constructor**: The constructor type for initialization with custom storage (e.g. `Set`, `Array`).
|
|
20
21
|
- **Shape**: The shape of element-based collection built on @typedly/data.
|
|
21
22
|
- **Customizable Storage**: Support for various storage types (`Set<T>`, `T[]`, etc.) via generics with add/remove/iterate.
|
|
@@ -27,6 +28,7 @@ A **TypeScript** type definitions package for data collections with customizable
|
|
|
27
28
|
- [Installation](#installation)
|
|
28
29
|
- [Api](#api)
|
|
29
30
|
- Interface
|
|
31
|
+
- [`CollectionAdapter`](#collectionadapter)
|
|
30
32
|
- [`CollectionShape`](#collectionshape)
|
|
31
33
|
- Type
|
|
32
34
|
- [`CollectionConstructor`](#collectionconstructor)
|
|
@@ -49,6 +51,7 @@ npm install @typedly/collection --save-peer
|
|
|
49
51
|
```typescript
|
|
50
52
|
import {
|
|
51
53
|
// Interface.
|
|
54
|
+
CollectionAdapter,
|
|
52
55
|
CollectionShape,
|
|
53
56
|
// Type.
|
|
54
57
|
CollectionConstructor
|
|
@@ -57,6 +60,14 @@ import {
|
|
|
57
60
|
|
|
58
61
|
### Interface
|
|
59
62
|
|
|
63
|
+
### `CollectionAdapter`
|
|
64
|
+
|
|
65
|
+
The adapter interface for collections.
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { CollectionAdapter } from '@typedly/collection';
|
|
69
|
+
```
|
|
70
|
+
|
|
60
71
|
### `CollectionShape`
|
|
61
72
|
|
|
62
73
|
```typescript
|
package/package.json
CHANGED
|
@@ -51,6 +51,18 @@ interface CollectionShape<T, V = any> extends DataShape<V> {
|
|
|
51
51
|
get [Symbol.iterator](): Iterator<T>;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* @description The adapter interface for collections.
|
|
56
|
+
* @export
|
|
57
|
+
* @interface CollectionAdapter
|
|
58
|
+
* @template Element The type of elements in the collection.
|
|
59
|
+
* @template Type The type of the value in the collection, data of elements.
|
|
60
|
+
* @extends {CollectionShape<Element, Type>}
|
|
61
|
+
*/
|
|
62
|
+
interface CollectionAdapter<Element, Type> extends CollectionShape<Element, Type> {
|
|
63
|
+
version: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
/**
|
|
55
67
|
* @description The constructor type for CollectionShape.
|
|
56
68
|
* @export
|
|
@@ -60,4 +72,4 @@ interface CollectionShape<T, V = any> extends DataShape<V> {
|
|
|
60
72
|
*/
|
|
61
73
|
type CollectionConstructor<T, V, C extends CollectionShape<T, V>> = ConstrainedConstructor<CollectionShape<T, V>, C, T[]>;
|
|
62
74
|
|
|
63
|
-
export type { CollectionConstructor, CollectionShape };
|
|
75
|
+
export type { CollectionAdapter, CollectionConstructor, CollectionShape };
|