2.2.4 • Published 6 months ago
@atcute/cbor v2.2.4
@atcute/cbor
lightweight DASL dCBOR42 (deterministic CBOR with tag 42) codec library for AT Protocol.
the specific profile being implemented is IPLD DAG-CBOR, with some additional notes to keep in mind:
undefinedtypes are still forbidden, except for when they are in amaptype, where fields will be omitted instead, which makes it easier to construct objects to then pass to the encoder.byteandlinktypes are represented by atproto's lex-json interfaces, but because these involve string codec and parsing, they are done lazily byBytesWrapperandCidLinkWrapperinstances.- use
fromBytesandfromCidLinkto convert them to Uint8Array or CID interface respectively, without hitting the string conversion path. - use
toBytesandtoCidLinkfor the other direction.
- use
- integers can't exceed JavaScript's safe integer range, no bigint conversions will occur as they will be thrown instead if encountered.
import { encode } from '@atcute/cbor';
const record = {
$type: 'app.bsky.feed.post',
createdAt: '2024-08-18T03:18:24.000Z',
langs: ['en'],
text: 'hello world!',
};
const cbor = encode(record);
// ^? Uint8Array(90) [ ... ]Implementation based on the excellent microcbor library.
1.0.7
10 months ago
1.0.6
12 months ago
2.2.1
7 months ago
2.1.2
9 months ago
2.2.0
8 months ago
2.1.1
10 months ago
2.2.3
6 months ago
2.2.2
6 months ago
2.1.3
9 months ago
2.2.4
6 months ago
2.1.0
10 months ago
2.0.1
10 months ago
2.0.0
10 months ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago