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

graph-cache

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-cache - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

5

build/graph_utils.js

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

var diff = require('lodash.differenceby');
var includes = require('lodash.includes');

@@ -10,3 +11,5 @@ function getDepencies(g, nodes, acc) {

return nacc.concat(g.predecessors(node));
}, []);
}, []).filter(function (el) {
return !includes(acc, el);
});

@@ -13,0 +16,0 @@ if (newNodes.length === 0) {

6

lib/graph_utils.js
const uniq = require('lodash.uniq');
const diff = require('lodash.differenceby');
const includes = require('lodash.includes');
function getDepencies(g, nodes, acc) {
const newNodes = nodes.reduce((nacc, node) =>
nacc.concat(g.predecessors(node)), []);
const newNodes = nodes
.reduce((nacc, node) => nacc.concat(g.predecessors(node)), [])
.filter((el) => !includes(acc, el));

@@ -8,0 +10,0 @@ if (newNodes.length === 0) {

{
"name": "graph-cache",
"version": "1.0.3",
"version": "1.0.4",
"description": "",

@@ -25,2 +25,3 @@ "main": "index.js",

"lodash.differenceby": "^4.6.0",
"lodash.includes": "^4.3.0",
"lodash.uniq": "^4.3.0",

@@ -27,0 +28,0 @@ "object-assign": "^4.1.0"

const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
const { loadTestFile, testSign, testGraph } = require('../utils/test_utils');
const { loadTestFile, testSign, testGraph, loadCyclicGraph } = require('../utils/test_utils');

@@ -29,3 +29,18 @@ chai.use(chaiAsPromised);

it('can check cycle graphs not changed', () =>
loadCyclicGraph(true).then(([g, files, names]) => {
return expect(checkFileCache(g, testSign, files[0], names[0]))
.eventually.eql([]);
})
);
it('can check cycle graphs changed', () =>
loadCyclicGraph(true).then(([g, files, names]) => {
g.setNode(names[1], 2123);
return expect(checkFileCache(g, testSign, files[0], names[0]))
.eventually.eql([names[1]]);
})
);
it('returns true if file has no deps and signatures match', () =>

@@ -32,0 +47,0 @@ loadTestFile('1.txt').then(([file, filename]) => {

@@ -152,3 +152,3 @@ const chai = require('chai');

loadCyclicGraph().then(gg => {
return updateGraph(g, testSign, loadCyclicGraph, '', getName(1))
return updateGraph(g, testSign, loadCyclicGraph.bind(null, false), '', getName(1))
.then(nwg => compareGraphs(nwg, gg))

@@ -155,0 +155,0 @@ })

@@ -90,5 +90,8 @@ const Graph = require('graphlib').Graph;

function loadCyclicGraph() {
return load2Graph().then((g) => {
function loadCyclicGraph(info = false) {
return load2Graph(true).then(([g, files, names]) => {
g.setEdge(getName(1), getName(2));
if (info) {
return [g, files, names];
}
return g;

@@ -95,0 +98,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