You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix!: simplify the codec interface, remove helper methods & classes
BREAKING CHANGE:
* Removes the codecs/codec export - there is no longer a helper function to
building codecs, they should instead assert that they conform to the
`BlockCodec` type, see json and raw examples. The `codec()` helper and
`Encoder` and `Decoder` classes have been removed. Use type assertions to
conform to simple signatures for now. In the future we may introduce more
composable codec functionality which may require codecs to lean on additional
helpers and classes.
* Fix bases/base64 type export to be usable
Copy file name to clipboardExpand all lines: README.md
+12-32
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,8 @@
1
1
# multiformats
2
2
3
-
This library defines common interfaces and low level building blocks for varios inter-related multiformat technologies (multicodec, multihash, multibase,
4
-
and CID). They can be used to implement custom custom base
5
-
encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.
3
+
This library defines common interfaces and low level building blocks for varios inter-related multiformat technologies (multicodec, multihash, multibase, and CID). They can be used to implement custom custom base encoders / decoders / codecs, codec encoders /decoders and multihash hashers that comply to the interface that layers above assume.
6
4
7
-
Library provides implementations for most basics and many others can be found in linked repositories.
5
+
This library provides implementations for most basics and many others can be found in linked repositories.
provides quite a few implementations that can be imported:
46
+
CIDs can be serialized to string representation using multibase encoders that implement [`MultibaseEncoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides quite a few implementations that can be imported:
Parsing CID string serialized CIDs requires multibase decoder that implements
59
-
[`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. Library provides a
60
-
decoder for every encoder it provides:
54
+
Parsing CID string serialized CIDs requires multibase decoder that implements [`MultibaseDecoder`](https://github.com/multiformats/js-multiformats/blob/master/src/bases/interface.ts) interface. This library provides a decoder for every encoder it provides:
Library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts)
97
-
and utility function to take care of the boilerplate when implementing them:
90
+
This library defines [`BlockEncoder`, `BlockDecoder` and `BlockCodec` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/codecs/interface.ts). Codec implementations should conform to the `BlockCodec` interface which implements both `BlockEncoder` and `BlockDecoder`.
Just like with multibase, here codecs are duals of `encoder` and `decoder` parts,
113
-
but they also implement both interfaces for convenience:
114
-
115
-
```js
116
-
consthello=json.encoder.encode({ hello:'world' })
117
-
json.decode(b1)
118
-
//> { hello: 'world' }
102
+
}
119
103
```
120
104
121
105
### Multihash Hashers
122
106
123
-
This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts)
124
-
and convinient function for implementing them:
107
+
This library defines [`MultihashHasher` and `MultihashDigest` interfaces](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts) and convinient function for implementing them:
0 commit comments