@atproto/common 0.4.6 → 0.4.7
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 +6 -0
- package/dist/ipld-multi.d.ts.map +1 -1
- package/dist/ipld-multi.js +6 -1
- package/dist/ipld-multi.js.map +1 -1
- package/package.json +1 -1
- package/src/ipld-multi.ts +7 -1
- package/tests/ipld-multi.test.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atproto/common
|
|
2
2
|
|
|
3
|
+
## 0.4.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#3481](https://github.com/bluesky-social/atproto/pull/3481) [`52c687a05`](https://github.com/bluesky-social/atproto/commit/52c687a05c70d5660fae1de9e1bbc6297f37f1f4) Thanks [@dholms](https://github.com/dholms)! - Parse safe uint64 as number
|
|
8
|
+
|
|
3
9
|
## 0.4.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/ipld-multi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipld-multi.d.ts","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ipld-multi.d.ts","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,eAAe,YAAa,UAAU,KAAG,OAAO,EAM5D,CAAA"}
|
package/dist/ipld-multi.js
CHANGED
|
@@ -42,9 +42,14 @@ cborx.addExtension({
|
|
|
42
42
|
return cid_1.CID.decode(bytes.subarray(1)); // ignore leading 0x00
|
|
43
43
|
},
|
|
44
44
|
});
|
|
45
|
+
const decoder = new cborx.Decoder({
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
int64AsNumber: true, // not in types for some reason
|
|
48
|
+
useRecords: false,
|
|
49
|
+
});
|
|
45
50
|
const cborDecodeMulti = (encoded) => {
|
|
46
51
|
const decoded = [];
|
|
47
|
-
|
|
52
|
+
decoder.decodeMultiple(encoded, (value) => {
|
|
48
53
|
decoded.push(value);
|
|
49
54
|
});
|
|
50
55
|
return decoded;
|
package/dist/ipld-multi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipld-multi.js","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA+B;AAC/B,0CAAsC;AAEtC,kCAAkC;AAClC,0CAA0C;AAC1C,iCAAiC;AACjC,KAAK,CAAC,YAAY,CAAC;IACjB,KAAK,EAAE,SAAG;IACV,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,MAAM,EAAE,CAAC,KAAiB,EAAO,EAAE;QACjC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,SAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,sBAAsB;IAC7D,CAAC;CACF,CAAC,CAAA;AAEK,MAAM,eAAe,GAAG,CAAC,OAAmB,EAAa,EAAE;IAChE,MAAM,OAAO,GAAc,EAAE,CAAA;IAC7B,
|
|
1
|
+
{"version":3,"file":"ipld-multi.js","sourceRoot":"","sources":["../src/ipld-multi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAA+B;AAC/B,0CAAsC;AAEtC,kCAAkC;AAClC,0CAA0C;AAC1C,iCAAiC;AACjC,KAAK,CAAC,YAAY,CAAC;IACjB,KAAK,EAAE,SAAG;IACV,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,MAAM,EAAE,CAAC,KAAiB,EAAO,EAAE;QACjC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QACvE,CAAC;QACD,OAAO,SAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC,sBAAsB;IAC7D,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC;IAChC,aAAa;IACb,aAAa,EAAE,IAAI,EAAE,+BAA+B;IACpD,UAAU,EAAE,KAAK;CAClB,CAAC,CAAA;AAEK,MAAM,eAAe,GAAG,CAAC,OAAmB,EAAa,EAAE;IAChE,MAAM,OAAO,GAAc,EAAE,CAAA;IAC7B,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;QACxC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACrB,CAAC,CAAC,CAAA;IACF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B"}
|
package/package.json
CHANGED
package/src/ipld-multi.ts
CHANGED
|
@@ -18,9 +18,15 @@ cborx.addExtension({
|
|
|
18
18
|
},
|
|
19
19
|
})
|
|
20
20
|
|
|
21
|
+
const decoder = new cborx.Decoder({
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
int64AsNumber: true, // not in types for some reason
|
|
24
|
+
useRecords: false,
|
|
25
|
+
})
|
|
26
|
+
|
|
21
27
|
export const cborDecodeMulti = (encoded: Uint8Array): unknown[] => {
|
|
22
28
|
const decoded: unknown[] = []
|
|
23
|
-
|
|
29
|
+
decoder.decodeMultiple(encoded, (value) => {
|
|
24
30
|
decoded.push(value)
|
|
25
31
|
})
|
|
26
32
|
return decoded
|
package/tests/ipld-multi.test.ts
CHANGED
|
@@ -22,4 +22,13 @@ describe('ipld decode multi', () => {
|
|
|
22
22
|
expect(decoded[0]).toEqual(one)
|
|
23
23
|
expect(decoded[1]).toEqual(two)
|
|
24
24
|
})
|
|
25
|
+
|
|
26
|
+
it('parses safe ints as number', async () => {
|
|
27
|
+
const one = {
|
|
28
|
+
test: Number.MAX_SAFE_INTEGER,
|
|
29
|
+
}
|
|
30
|
+
const encoded = cborEncode(one)
|
|
31
|
+
const decoded = cborDecodeMulti(encoded)
|
|
32
|
+
expect(Number.isInteger(decoded[0]?.['test'])).toBe(true)
|
|
33
|
+
})
|
|
25
34
|
})
|