This repository was archived by the owner on Sep 3, 2021. It is now read-only.
File tree 2 files changed +7
-11
lines changed
2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change 35
35
"url" : " https://github.com/ipld/js-cid/issues"
36
36
},
37
37
"dependencies" : {
38
+ "class-is" : " ^1.1.0" ,
38
39
"multibase" : " ~0.4.0" ,
39
40
"multicodec" : " ~0.2.7" ,
40
41
"multihashes" : " ~0.4.13"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const multicodec = require('multicodec')
6
6
const codecs = require ( 'multicodec/src/base-table' )
7
7
const multihash = require ( 'multihashes' )
8
8
const CIDUtil = require ( './cid-util' )
9
+ const withIs = require ( 'class-is' )
9
10
10
11
/**
11
12
* @typedef {Object } SerializedCID
@@ -53,7 +54,7 @@ class CID {
53
54
*
54
55
*/
55
56
constructor ( version , codec , multihash ) {
56
- if ( CID . isCID ( version ) ) {
57
+ if ( module . exports . isCID ( version ) ) {
57
58
let cid = version
58
59
this . version = cid . version
59
60
this . codec = cid . codec
@@ -215,15 +216,6 @@ class CID {
215
216
this . multihash . equals ( other . multihash )
216
217
}
217
218
218
- /**
219
- * Test if the given input is a CID.
220
- *
221
- * @param {any } other
222
- * @returns {bool }
223
- */
224
- static isCID ( other ) {
225
- return ! ( CIDUtil . checkCIDComponents ( other ) )
226
- }
227
219
228
220
/**
229
221
* Test if the given input is a valid CID object.
@@ -242,4 +234,7 @@ class CID {
242
234
243
235
CID . codecs = codecs
244
236
245
- module . exports = CID
237
+ module . exports = withIs ( CID , {
238
+ className : 'CID' ,
239
+ symbolName : 'cids/CID' ,
240
+ } )
You can’t perform that action at this time.
0 commit comments