Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
dash(ast, function (node) {
var binding
if (isRequire(node, 'split-require')) {
if (onrequire) onrequire(node)
if (node.parent.type === 'VariableDeclarator') {
// var sr = require('split-require')
binding = scan.getBinding(node.parent.id)
if (binding) binding.getReferences().slice(1).forEach(onreference)
} else if (node.parent.type === 'AssignmentExpression') {
// sr = require('split-require')
binding = scan.getBinding(node.parent.left)
if (binding) binding.getReferences().slice(1).forEach(onreference)
} else {
// require('split-require')(...args)
onreference(node)
}
}
})
}
dash(ast, function (node) {
var binding
if (isRequire(node, 'split-require')) {
if (onrequire) onrequire(node)
if (node.parent.type === 'VariableDeclarator') {
// var sr = require('split-require')
binding = scan.getBinding(node.parent.id)
if (binding) binding.getReferences().slice(1).forEach(onreference)
} else if (node.parent.type === 'AssignmentExpression') {
// sr = require('split-require')
binding = scan.getBinding(node.parent.left)
if (binding) binding.getReferences().slice(1).forEach(onreference)
} else {
// require('split-require')(...args)
onreference(node)
}
}
})
}
function getDependencies (moduleWrapper) {
var deps = {}
if (moduleWrapper.params.length < 3) return deps
var req = scan.getBinding(moduleWrapper.params[2])
req.getReferences().forEach(function (ref) {
if (ref.parent.type === 'CallExpression' && ref.parent.callee === ref && ref.parent.arguments[0].type === 'Literal') {
deps[ref.parent.arguments[0].value] = ref.parent.arguments[0].value
}
})
return deps
}
function renameImport (row, node, name) {
if (node.parent.type === 'VariableDeclarator' && node.parent.id.type === 'Identifier') {
var binding = scan.getBinding(node.parent.id)
if (binding) {
renameBinding(binding, name)
removeVariableDeclarator(row, node.parent)
return
}
}
node.edit.update(name)
}