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

toposource

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toposource - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

23

package.json
{
"name": "toposource",
"version": "1.0.0",
"version": "1.0.1",
"description": "Directed graphs analyzer for parallel traversals",

@@ -20,10 +20,12 @@ "main": "./target/cjs/index.js",

"build": "concurrently 'npm:build:*'",
"build:esm": "node ./build.cjs && rename -f 's/\\.js$/\\.mjs/' target/esm/*.js",
"build:cjs": "node ./build.cjs --cjs",
"build:esm": "node ./src/scripts/build.cjs && rename -f 's/\\.js$/\\.mjs/' target/esm/*.js",
"build:cjs": "node ./src/scripts/build.cjs --cjs",
"build:dts": "tsc --emitDeclarationOnly --outDir target/dts",
"lint": "eslint src",
"lint:fix": "yarn style --fix",
"verify": "yarn lint && yarn test",
"test": "yarn test:unit",
"test:unit": "c8 -r html -r text -r lcov --exclude src/test -o ./target/coverage uvu -r tsm src/test/ts",
"build:docs": "typedoc --options src/main/typedoc",
"lint": "eslint -c src/test/lint/.eslintrc.json src",
"format": "yarn test:lint --fix",
"test": "concurrently 'npm:test:*'",
"test:lint": "eslint -c src/test/lint/.eslintrc.json src",
"test:unit": "c8 -r html -r text -r lcov --exclude ./src/test -o ./target/coverage uvu -r tsm src/test/ts",
"test:it": "uvu -r tsm src/test/js",
"test:bench": "node src/test/bench/index.mjs"

@@ -54,2 +56,3 @@ },

"tsm": "^2.3.0",
"typedoc": "^0.23.25",
"typescript": "^4.9.4",

@@ -67,3 +70,5 @@ "uvu": "^0.5.6"

"dependencies",
"acyclic"
"directed",
"acyclic",
"dag"
],

@@ -70,0 +75,0 @@ "contributors": [

# toposource
[![CI](https://github.com/semrel-extra/toposource/actions/workflows/ci.yaml/badge.svg?branch=master&event=push)](https://github.com/semrel-extra/toposource/actions/workflows/ci.yaml)
[![Maintainability](https://api.codeclimate.com/v1/badges/41fea7047ed5521e2075/maintainability)](https://codeclimate.com/github/semrel-extra/toposource/maintainability)

@@ -14,11 +15,13 @@ [![Test Coverage](https://api.codeclimate.com/v1/badges/41fea7047ed5521e2075/test_coverage)](https://codeclimate.com/github/semrel-extra/toposource/test_coverage)

{
next: new Map()
.set('a', ['b'])
.set('b', ['c'])
.set('d', ['c'])
.set('e', ['f']),
prev: new Map()
.set('b', ['a'])
.set('c', ['b', 'd'])
.set('f', ['e']),
next: new Map([
['a', ['b']],
['b', ['c']],
['d', ['c']],
['e', ['f']]
]),
prev: new Map([
['b', ['a']],
['c', ['b', 'd']],
['f', ['e']]
]),
sources: [ 'a', 'd', 'e' ],

@@ -38,4 +41,5 @@ queue: ['a', 'd', 'e', 'b', 'c', 'f'],

* [toposort](https://github.com/marcelklehr/toposort)
* [batching-toposort](https://github.com/glebec/batching-toposort)
## License
[MIT](./LICENSE)

@@ -35,3 +35,3 @@ "use strict";

const graphs = opts.graphs ? getGraphs(_edges, sources, next) : void 0;
const queue = opts.queue ? getQueue(sources, next) : void 0;
const queue = opts.queue ? getQueue(sources, next, prev) : void 0;
return {

@@ -45,3 +45,20 @@ next,

};
var getQueue = (sources, next) => [...mergeNested(new Set(sources), next).values()];
var getQueue = (sources, next, prev) => {
const nodes = /* @__PURE__ */ new Set();
const todo = [...sources];
const batch = /* @__PURE__ */ new Set();
for (const [i, node] of todo.entries()) {
if ((prev.get(node) || []).every((p) => nodes.has(p))) {
nodes.add(node);
pushToSet(batch, ...next.get(node) || []);
} else {
pushToSet(batch, node);
}
if (i === todo.length - 1) {
todo.push(...batch.values());
batch.clear();
}
}
return [...nodes.values()];
};
var getHops = (edges) => {

@@ -73,5 +90,3 @@ const next = /* @__PURE__ */ new Map();

same.sources.push(source);
for (const value of values) {
same.nodes.add(value);
}
pushToSet(same.nodes, ...values);
continue;

@@ -83,23 +98,22 @@ }

};
var checkLoop = (next) => {
for (const [node, children] of next) {
const desc = mergeNested(new Set(children), next);
if (desc.has(node)) {
throw new Error("Loop detected");
}
}
};
var pushToSet = (set, ...items) => {
for (const item of items) {
set.add(item);
}
return set;
};
var mergeNested = (nodes, deps) => {
for (const node of nodes) {
for (const child of deps.get(node) || []) {
nodes.add(child);
}
pushToSet(nodes, ...deps.get(node) || []);
}
return nodes;
};
var checkLoop = (next) => {
for (const [node, children] of next) {
const _children = new Set(children);
for (const child of _children) {
if (_children.has(node)) {
throw new Error("Loop detected");
}
for (const _child of next.get(child) || []) {
_children.add(_child);
}
}
}
};
// Annotate the CommonJS export names for ESM import in node:

@@ -106,0 +120,0 @@ 0 && (module.exports = {

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