Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

Commit

Permalink
Revert "fix: replace constructor.name with instanceof"
Browse files Browse the repository at this point in the history
This reverts commit 881d572.
  • Loading branch information
vmx committed Mar 8, 2018
1 parent 881d572 commit 55a87a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/dag-link/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const DAGLink = require('./index')

function isDagLink (link) {
return link && link.constructor && link instanceof DAGLink
return link && link.constructor && link.constructor.name === 'DAGLink'
}

function createDagLinkFromB58EncodedHash (link) {
Expand Down
5 changes: 2 additions & 3 deletions src/dag-node/addLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ const cloneData = dagNodeUtil.cloneData
const toDAGLink = dagNodeUtil.toDAGLink
const DAGLink = require('./../dag-link')
const create = require('./create')
const DAGNode = require('./index')

function addLink (node, link, callback) {
const links = cloneLinks(node)
const data = cloneData(node)

if ((link.constructor && link instanceof DAGLink)) {
if ((link.constructor && link.constructor.name === 'DAGLink')) {
// It's a DAGLink instance
// no need to do anything
} else if (link.constructor && link instanceof DAGNode) {
} else if (link.constructor && link.constructor.name === 'DAGNode') {
// It's a DAGNode instance
// convert to link
link = toDAGLink(link)
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function serialize (node, callback) {
let serialized

// If the node is not an instance of a DAGNode, the link.hash might be a Base58 encoded string; decode it
if (!(node instanceof DAGNode) && node.links) {
if (node.constructor.name !== 'DAGNode' && node.links) {
node.links = node.links.map((link) => {
return DAGLink.util.isDagLink(link) ? link : DAGLink.util.createDagLinkFromB58EncodedHash(link)
})
Expand Down

0 comments on commit 55a87a7

Please sign in to comment.