From 1c6e541756115b72e7721f505c15db5430c816fe Mon Sep 17 00:00:00 2001 From: Diogo Silva Date: Wed, 28 Mar 2018 16:19:40 +0100 Subject: [PATCH] feat: use class-is module for type checks --- package.json | 3 ++- src/index.js | 13 ++----------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 24157db..cdbb17e 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,8 @@ "chai": "^4.1.2" }, "dependencies": { - "cids": "^0.5.2" + "cids": "^0.5.2", + "class-is": "^1.0.0" }, "engines": { "node": ">=6.0.0", diff --git a/src/index.js b/src/index.js index c05d308..29d0627 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,7 @@ 'use strict' const CID = require('cids') +const withIs = require('class-is') /** * Represents an immutable block of data that is uniquely referenced with a cid. @@ -51,16 +52,6 @@ class Block { set cid (val) { throw new Error('Tried to change an immutable block') } - - /** - * Check if the given value is a Block. - * - * @param {any} other - * @returns {bool} - */ - static isBlock (other) { - return other && other.constructor.name === 'Block' - } } -module.exports = Block +module.exports = withIs(Block, { className: 'Block', symbolName: '@ipfs/js-ipfs-block/block' })