This repository was archived by the owner on Sep 3, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change 3535 "url" : " https://github.com/ipld/js-cid/issues"
3636 },
3737 "dependencies" : {
38+ "class-is" : " ^1.1.0" ,
3839 "multibase" : " ~0.4.0" ,
3940 "multicodec" : " ~0.2.7" ,
4041 "multihashes" : " ~0.4.13"
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const multicodec = require('multicodec')
66const codecs = require ( 'multicodec/src/base-table' )
77const multihash = require ( 'multihashes' )
88const CIDUtil = require ( './cid-util' )
9+ const withIs = require ( 'class-is' )
910
1011/**
1112 * @typedef {Object } SerializedCID
@@ -53,7 +54,7 @@ class CID {
5354 *
5455 */
5556 constructor ( version , codec , multihash ) {
56- if ( CID . isCID ( version ) ) {
57+ if ( module . exports . isCID ( version ) ) {
5758 let cid = version
5859 this . version = cid . version
5960 this . codec = cid . codec
@@ -215,15 +216,6 @@ class CID {
215216 this . multihash . equals ( other . multihash )
216217 }
217218
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- }
227219
228220 /**
229221 * Test if the given input is a valid CID object.
@@ -242,4 +234,7 @@ class CID {
242234
243235CID . codecs = codecs
244236
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