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
{{ message }}
This repository was archived by the owner on Sep 3, 2021. It is now read-only.
Relaxes input from requiring node `Buffer`s to being `Uint8Arrays`.
This also means that the `.buffer` and `.prefix` properties are now
`Uint8Array`s.
BREAKING CHANGES:
- node `Buffer`s have been replaced with `Uint8Array`s
- the `.buffer` property is now a `Uint8Array`
- the `.prefix` property is now a `Uint8Array`
You will need to use Node.js `Buffer` API compatible, if you are running inside the browser, you can access it by `multihash.Buffer` or you can install Feross's [Buffer](https://github.com/feross/buffer).
54
-
55
70
## Usage
56
71
57
-
You can create an instance from a CID string or CID Buffer
72
+
You can create an instance from a CID string or CID Uint8Array
58
73
59
74
```js
60
75
constCID=require('cids')
@@ -73,8 +88,9 @@ or by specifying the [cid version](https://github.com/multiformats/cid#versions)
@@ -119,7 +135,7 @@ instance. Throws an `Error` if not valid.
119
135
120
136
`codec` must be a string of a valid [registered codec](https://github.com/multiformats/multicodec/blob/master/table.csv).
121
137
122
-
`multihash` must be a `Buffer` instance of a valid [multihash](https://github.com/multiformats/multihash).
138
+
`multihash` must be a `Uint8Array` instance of a valid [multihash](https://github.com/multiformats/multihash).
123
139
124
140
`multibaseName` optional string. Must be a valid [multibase](https://github.com/multiformats/multibase/blob/master/multibase.csv) name. Default is `base58btc` for v0 CIDs or `base32` for v1 CIDs.
125
141
@@ -128,9 +144,9 @@ instance. Throws an `Error` if not valid.
128
144
Additionally, you can instantiate an instance from a base encoded
129
145
string.
130
146
131
-
### new CID(Buffer)
147
+
### new CID(Uint8Array)
132
148
133
-
Additionally, you can instantiate an instance from a buffer.
149
+
Additionally, you can instantiate an instance from a `Uint8Array`.
134
150
135
151
#### cid.codec
136
152
@@ -142,19 +158,19 @@ Property containing the CID version integer.
142
158
143
159
#### cid.multihash
144
160
145
-
Property containing the multihash buffer.
161
+
Property containing the multihash `Uint8Array`.
146
162
147
163
#### cid.multibaseName
148
164
149
165
Property containing the default base to use when calling `.toString`
150
166
151
-
#### cid.buffer
167
+
#### cid.bytes
152
168
153
-
Property containing the full CID encoded as a `Buffer`.
169
+
Property containing the full CID encoded as a `Uint8Array`.
154
170
155
171
#### cid.prefix
156
172
157
-
Proprety containing a buffer of the CID version, codec, and the prefix
173
+
Proprety containing a `Uint8Array` of the CID version, codec, and the prefix
158
174
section of the multihash.
159
175
160
176
#### cid.toV0()
@@ -174,7 +190,7 @@ Returns a base encoded string of the CID. Defaults to the base encoding in `this
174
190
The value of `this.multibaseName` depends on how the instance was constructed:
175
191
176
192
1. If the CID was constructed from an object that already had a multibase (a string or an existing CID) then it retains that base.
177
-
2. If the CID was constructed from an object that _did not_ have a multibase (a buffer, or by passing only version + codec + multihash to the constructor), then `multibaseName` will be `base58btc` for a v0 CID or `base32` for a v1 CID.
193
+
2. If the CID was constructed from an object that _did not_ have a multibase (a `Uint8Array`, or by passing only version + codec + multihash to the constructor), then `multibaseName` will be `base58btc` for a v0 CID or `base32` for a v1 CID.
0 commit comments