Socket
Socket
Sign inDemoInstall

commonjs-walker

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonjs-walker - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

18

lib/circular.js

@@ -5,3 +5,11 @@ 'use strict';

// Scenario:
// One day, `to` depends on `from`,
// So we suppose that there is a trace goes back the dependency chain
// from `from` up to `to`:
// ```
//
// ```
// @param {Object} from The from node, the spring generations

@@ -13,3 +21,3 @@ // @param {Object} to The node to be tested, the ancestors

circular.trace = function (from, to) {
var trace = [from];
var trace = [to];

@@ -25,3 +33,3 @@ if (from === to) {

circular.lookBack = function (from, to, trace) {
trace.push(to);
trace.push(from);

@@ -34,3 +42,3 @@ if (from === to) {

// if meets the end, just pop.
if (!to.dependents || to.dependents.length === 0) {
if (!from.dependencies || from.dependencies.length === 0) {
trace.pop();

@@ -40,4 +48,4 @@ return null;

var found = to.dependents.some(function (new_to) {
return circular.lookBack(from, new_to, trace);
var found = from.dependencies.some(function (new_from) {
return circular.lookBack(new_from, to, trace);
});

@@ -44,0 +52,0 @@

{
"name": "commonjs-walker",
"version": "1.0.1",
"version": "1.0.2",
"description": "Analyzer and tree walker for commonjs.",

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

@@ -46,6 +46,6 @@ 'use strict';

name: 'b',
dependents: [
dependencies: [
{
name: 'c',
dependents: [
dependencies: [
{

@@ -65,3 +65,3 @@ name: 'd'

var result = circular.trace(a, b).map(function (item) {
var result = circular.trace(b, a).map(function (item) {
return item.name;

@@ -68,0 +68,0 @@ });

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