@atproto/lex-installer 0.0.14 → 0.0.16
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/CHANGELOG.md +24 -0
- package/dist/fs.d.ts +98 -0
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +98 -0
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -0
- package/dist/index.js.map +1 -1
- package/dist/lex-installer.d.ts +135 -0
- package/dist/lex-installer.d.ts.map +1 -1
- package/dist/lex-installer.js +107 -0
- package/dist/lex-installer.js.map +1 -1
- package/dist/lexicons-manifest.d.ts +28 -0
- package/dist/lexicons-manifest.d.ts.map +1 -1
- package/dist/lexicons-manifest.js +25 -0
- package/dist/lexicons-manifest.js.map +1 -1
- package/dist/nsid-map.d.ts +46 -5
- package/dist/nsid-map.d.ts.map +1 -1
- package/dist/nsid-map.js +46 -5
- package/dist/nsid-map.js.map +1 -1
- package/dist/nsid-set.d.ts +41 -5
- package/dist/nsid-set.d.ts.map +1 -1
- package/dist/nsid-set.js +41 -5
- package/dist/nsid-set.js.map +1 -1
- package/package.json +8 -8
- package/src/fs.ts +98 -0
- package/src/index.ts +85 -0
- package/src/lex-installer.ts +137 -0
- package/src/lexicons-manifest.ts +28 -0
- package/src/nsid-map.ts +46 -5
- package/src/nsid-set.ts +41 -5
package/src/nsid-set.ts
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import { NSID } from '@atproto/syntax'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* A Set implementation that maps values of type K to an internal representation
|
|
5
|
-
* I. Value identity is determined by the {@link Object.is} comparison of the
|
|
6
|
-
* encoded values.
|
|
4
|
+
* A Set implementation that maps values of type K to an internal representation I.
|
|
7
5
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Value identity is determined by the {@link Object.is} comparison of the
|
|
7
|
+
* encoded values. This is useful for complex types that can be serialized
|
|
8
|
+
* to a unique primitive representation (typically strings).
|
|
9
|
+
*
|
|
10
|
+
* @typeParam K - The external value type stored in the set
|
|
11
|
+
* @typeParam I - The internal encoded type used for identity comparison
|
|
10
12
|
*/
|
|
11
13
|
export class MappedSet<K, I = any> implements Set<K> {
|
|
12
14
|
private set = new Set<I>()
|
|
13
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Creates a new MappedSet with custom encoding/decoding functions.
|
|
18
|
+
*
|
|
19
|
+
* @param encodeValue - Function to convert external values to internal representation
|
|
20
|
+
* @param decodeValue - Function to convert internal representation back to external values
|
|
21
|
+
*/
|
|
14
22
|
constructor(
|
|
15
23
|
private readonly encodeValue: (val: K) => I,
|
|
16
24
|
private readonly decodeValue: (enc: I) => K,
|
|
@@ -67,7 +75,35 @@ export class MappedSet<K, I = any> implements Set<K> {
|
|
|
67
75
|
[Symbol.toStringTag]: string = 'MappedSet'
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
/**
|
|
79
|
+
* A Set specialized for storing NSID (Namespaced Identifier) values.
|
|
80
|
+
*
|
|
81
|
+
* NSIDs are compared by their string representation, allowing different
|
|
82
|
+
* NSID object instances with the same value to be treated as equal.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { NsidSet } from '@atproto/lex-installer'
|
|
87
|
+
* import { NSID } from '@atproto/syntax'
|
|
88
|
+
*
|
|
89
|
+
* const nsidSet = new NsidSet()
|
|
90
|
+
*
|
|
91
|
+
* nsidSet.add(NSID.from('app.bsky.feed.post'))
|
|
92
|
+
* nsidSet.add(NSID.from('app.bsky.actor.profile'))
|
|
93
|
+
*
|
|
94
|
+
* // Check membership
|
|
95
|
+
* nsidSet.has(NSID.from('app.bsky.feed.post')) // true
|
|
96
|
+
*
|
|
97
|
+
* // Iterate over NSIDs
|
|
98
|
+
* for (const nsid of nsidSet) {
|
|
99
|
+
* console.log(nsid.toString())
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
70
103
|
export class NsidSet extends MappedSet<NSID, string> {
|
|
104
|
+
/**
|
|
105
|
+
* Creates a new empty NsidSet.
|
|
106
|
+
*/
|
|
71
107
|
constructor() {
|
|
72
108
|
super(
|
|
73
109
|
(val) => val.toString(),
|