audit.js
function getLockfileDependencies(root) {
  var deps = {};
  if (root.name && root.version) {
    deps[root.name + "@" + root.version] = {
      "pm": "npm",
      "name": root.name,
      "version": root.version
    };
  }

  if (root.dependencies) {
    for (var name in root.dependencies) {
      var dep = root.dependencies[name];
      if (dep.version) {
        deps[name + "@" + dep.version] = {
          "pm": "npm",
          "name": name,
          "version": dep.version
        };
      }

      var childDeps = getLockfileDependencies(root.dependencies[name]);
      for (var attr in childDeps) {
        deps[attr] = childDeps[attr];
      }
    }
  }

  return Object.keys(deps).map(function (k) { return deps[k];});
}
function getLockfileDependencies(root) {
  var deps = {};
  if (root.name && root.version) {
    deps[root.name + "@" + root.version] = {
      "pm": "npm",
      "name": root.name,
      "version": root.version
    };
  }

  if (root.dependencies) {
    for (var name in root.dependencies) {
      var dep = root.dependencies[name];
      if (dep.version) {
        deps[name + "@" + dep.version] = {
          "pm": "npm",
          "name": name,
          "version": dep.version
        };
      }

      var childDeps = getLockfileDependencies(root.dependencies[name]);
      for (var attr in childDeps) {
        deps[attr] = childDeps[attr];
      }
    }
  }

  return Object.keys(deps).map(function (k) { return deps[k];});
}
function getLockfileDependencies ( root ) { var deps = { } ; if ( root . name && root . version ) { deps [ root . name + "@" + root . version ] = { "pm" : "npm" , "name" : root . name , "version" : root . version } ; } if ( root . dependencies ) { for ( var name in root . dependencies ) { var dep = root . dependencies [ name ] ; if ( dep . version ) { deps [ name + "@" + dep . version ] = { "pm" : "npm" , "name" : name , "version" : dep . version } ; } var childDeps = getLockfileDependencies ( root . dependencies [ name ] ) ; for ( var attr in childDeps ) { deps [ attr ] = childDeps [ attr ] ; } } } return Object . keys ( deps ) . map ( function ( k ) { return deps [ k ] ; } ) ; }
Given packag-lock.json data, produce a list of dependencies
Given packag - lock . json data produce a list of dependencies