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

Revert "replace constructor.name with instanceof so uglify can mangle and compress" #59

Merged
merged 1 commit into from
Mar 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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