Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var mdeps = require('module-deps')
, builtins = require('builtins')
, lodash = require('lodash')
, used = []
;
function filter (id) {
if (builtins.indexOf(id) === -1) return true
used.push(id)
return false
}
var md = mdeps({filter:filter})
md.on('data', function (obj) {
console.log(obj.file)
})
var request = require(__dirname+'/tmp/node_modules/request/package.json').main || 'index.js'
request = __dirname+'/tmp/node_modules/request/'+request
md.end({ file: request });
md.on('end', function () {
console.log('used', lodash.unique(used))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment