Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

es6-deps

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-deps - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

test/files/collide/a.js

23

index.js

@@ -73,6 +73,5 @@ 'use strict';

var ignorePattern = opt.ignorePattern || /^\s+$/;
var status = {};
var cache = this.cache;
var self = this;
status[filepath] = true;
var stack = [];

@@ -104,5 +103,13 @@ function _get(content, filepath) {

}
if (status[_name]) return; // cyclic, and ignore
status[_name] = true;
if (!cache[_name]) cache[_name] = _get(fs.readFileSync(_name, 'utf-8'), _name);
if (stack.indexOf(_name) > -1) {
//console.log('found pontential cyclic error! @', stack.indexOf(name) ,stack.concat(name).join(' -> '));
return; // cyclic, and ignore
}
stack.push(_name);
try {
if (!cache[_name]) cache[_name] = _get(fs.readFileSync(_name, 'utf-8'), _name);
} catch (e) {
// do nothing
}
stack.pop(_name);
deps.push.apply(deps, cache[_name].concat(_name));

@@ -134,3 +141,7 @@ } catch (e) {

content = content || fs.readFileSync(filepath, 'utf-8');
return _get(content, filepath);
stack.push(filepath);
var deps = _get(content, filepath);
return deps.filter(function (dep, i) {
return deps.indexOf(dep) === i;
});
}

@@ -137,0 +148,0 @@ }]);

{
"name": "es6-deps",
"version": "1.1.5",
"version": "1.1.6",
"description": "a simple util to get es6/jsx dependencies",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -66,6 +66,5 @@ var isdir = require('isdir');

const ignorePattern = opt.ignorePattern || /^\s+$/;
var status = {};
var cache = this.cache;
var self = this;
status[filepath] = true;
var stack = [];

@@ -91,5 +90,13 @@ function _get(content, filepath) {

}
if (status[name]) return; // cyclic, and ignore
status[name] = true;
if (!cache[name]) cache[name] = _get(fs.readFileSync(name, 'utf-8'), name);
if (stack.indexOf(name) > -1) {
//console.log('found pontential cyclic error! @', stack.indexOf(name) ,stack.concat(name).join(' -> '));
return; // cyclic, and ignore
}
stack.push(name);
try {
if (!cache[name]) cache[name] = _get(fs.readFileSync(name, 'utf-8'), name);
} catch (e) {
// do nothing
}
stack.pop(name);
deps.push.apply(deps, cache[name].concat(name));

@@ -107,4 +114,6 @@ } catch (e) {

content = content || fs.readFileSync(filepath, 'utf-8');
return _get(content, filepath);
stack.push(filepath);
var deps = _get(content, filepath);
return deps.filter((dep, i) => deps.indexOf(dep) === i);
}
}

@@ -58,2 +58,20 @@ require('babel/register');

});
it('cylic', function () {
var data = dep.getDeps(file('cylic.js'));
assert.ok(data.indexOf(file('cylic2.js')) > -1)
assert.ok(data.indexOf(file('cylic3.js')) > -1)
assert.ok(data.length === 2);
});
it('cache not collide', function () {
var dep = new Dep();
var dataA = dep.getDeps(file('collide/a.js'));
var dataB = dep.getDeps(file('collide/b.js'));
assert.deepEqual(dataA.sort(), [
file('collide/c.js'),
file('collide/d.js'),
].sort());
assert.deepEqual(dataA.sort(), dataB.sort());
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc