Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 6b6873b

Browse files
committed
fix: migrate to class-is for instance comparise, fixes #53
1 parent f47e68c commit 6b6873b

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Diff for: package.json

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
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"

Diff for: src/index.js

+6-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const multicodec = require('multicodec')
66
const codecs = require('multicodec/src/base-table')
77
const multihash = require('multihashes')
88
const 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

243235
CID.codecs = codecs
244236

245-
module.exports = CID
237+
module.exports = withIs(CID, {
238+
className: 'CID',
239+
symbolName: 'cids/CID',
240+
})

0 commit comments

Comments
 (0)