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
or by specifying the [cid version](https://github.com/multiformats/cid#versions), [multicodec name](https://github.com/multiformats/multicodec/blob/master/table.csv) and [multihash](https://github.com/multiformats/multihash):
The string form of CIDs currently defaults to `base58btc` flavour. (This is [soon to change to `base32`](https://github.com/ipfs/ipfs/issues/337). When creating a new instance you can optionally specify the default multibase to use when calling `toBaseEncodedString()` or `toString()`
@@ -80,17 +110,19 @@ order to handle CID objects from different versions of this module.
80
110
81
111
### CID.validateCID(cid)
82
112
83
-
Validates the different components (version, codec, multihash) of the CID
113
+
Validates the different components (version, codec, multihash, multibaseName) of the CID
84
114
instance. Returns true if valid, false if not valid.
85
115
86
-
### new CID(version, codec, multihash)
116
+
### new CID(version, codec, multihash, [multibaseName])
87
117
88
-
`version` must be either 0 or 1.
118
+
`version` must be [either 0 or 1](https://github.com/multiformats/cid#versions).
89
119
90
120
`codec` must be a string of a valid [registered codec](https://github.com/multiformats/multicodec/blob/master/table.csv).
91
121
92
122
`multihash` must be a `Buffer` instance of a valid [multihash](https://github.com/multiformats/multihash).
93
123
124
+
`multibaseName` optional string. Must be a valid [multibase](https://github.com/multiformats/multibase/blob/master/multibase.csv) name. Default is `base58btc`.
125
+
94
126
### new CID(baseEncodedString)
95
127
96
128
Additionally, you can instantiate an instance from a base encoded
@@ -112,6 +144,10 @@ Property containing the CID version integer.
112
144
113
145
Property containing the multihash buffer.
114
146
147
+
#### cid.multibaseName
148
+
149
+
Property containing the default base to use when calling `.toString`
150
+
115
151
#### cid.buffer
116
152
117
153
Property containing the full CID encoded as a `Buffer`.
@@ -131,9 +167,13 @@ Throws if codec is not `dag-pb`.
0 commit comments