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

async-bfs

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-bfs - npm Package Compare versions

Comparing version 0.1.7 to 0.1.8

53

lib/bfs.js

@@ -18,36 +18,25 @@ var async = require('async');

function moveQueueTask(node, callback) {
try {
moves(depth, node, function(err, newNodes) {
if (err) return callback(err);
if (foundGoal || !newNodes || !newNodes.length)
return callback();
var goalQueue = async.queue(goalQueueTask, goal.parallel || 4);
goalQueue.drain = callback;
newNodes.forEach(function(newNode) {
if (visited.hasOwnProperty(newNode)) return;
nodeQueue.push(newNode);
moves(depth, node, function(err, newNodes) {
if (err) return callback(err);
if (foundGoal || !newNodes || !newNodes.length)
return callback();
var goalQueue = async.queue(goalQueueTask, goal.parallel || 4);
goalQueue.drain = callback;
newNodes.forEach(function(newNode) {
if (visited.hasOwnProperty(newNode)) return;
nodeQueue.push(newNode);
visited[newNode] = {from: node};
goalQueue.push([newNode]);
});
if (!goalQueue.length()) return callback();
function goalQueueTask(newNode, goalCallback) {
if (foundGoal) return goalCallback();
goal(newNode, function(err, isGoal) {
visited[newNode] = {from: node};
goalQueue.push([newNode]);
if (err) return goalCallback(err);
if (isGoal) foundGoal = {node: newNode};
goalCallback();
});
if (!goalQueue.length()) return callback();
function goalQueueTask(newNode, goalCallback) {
if (foundGoal) return goalCallback();
goal(newNode, function(err, isGoal) {
visited[newNode] = {from: node};
if (err) return goalCallback(err);
if (isGoal) foundGoal = {node: newNode};
goalCallback();
});
};
});
} catch (e) {
// In large graphs you may get a Maximum call stack size
// exceeded error. Its best to reply with an error instead
// of dying
try {
return callback(e);
} catch (e) {
// callback was already called.
}
}
};
});
}

@@ -54,0 +43,0 @@ function moveQueueDone() {

{
"name": "async-bfs",
"version": "0.1.7",
"version": "0.1.8",
"description": "Flexible functional async breadth first search",

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

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