New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bfs-as-promised

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bfs-as-promised - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

6

package.json
{
"name": "bfs-as-promised",
"version": "1.0.1",
"version": "1.0.2",
"description": "Breadth-first search (BFS) using promise (Bluebird)",

@@ -27,6 +27,6 @@ "main": "lib/bfs.js",

"compile": "babel src --out-dir lib --source-maps --minified",
"test-coveralls": "babel-node ./node_modules/.bin/istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"test-coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"cover": "istanbul cover _mocha --include-all-sources -x **/lib/**",
"lint": "eslint . --ignore-path .gitignore",
"test": "babel-node ./node_modules/.bin/mocha"
"test": "mocha"
},

@@ -33,0 +33,0 @@ "devDependencies": {

@@ -1,2 +0,2 @@

# BFS as Promised — Promisified Breadth-First Search.
#BFS as Promised — Promisified Breadth-First SearchFinder.

@@ -14,14 +14,14 @@ [![NPM Version][npm-image]][npm-url]

const graph = new Map([
[1, [2, 3]],
[2, [3, 4]],
[3, []],
[4, [5]]
])
[1, [2, 3]],
[2, [3, 4]],
[3, []],
[4, [5]]
])
const getMoves = (fromNodes) => {
const res = new Map()
return Promise
.each(fromNodes, (fromNode) => {
res.set(fromNode, graph.get(fromNode) || [])
})
.return(res)
const res = new Map()
return Promise
.each(fromNodes, (fromNode) => {
res.set(fromNode, graph.get(fromNode) || [])
})
.return(res)
}

@@ -39,9 +39,8 @@

```
###Parameters:
#### start
####start
Assuming we are trying to find the shortest path from node __A__ to node __B__. Start parameter will be node __A__.
#### getMoves(fromNodes, depth)
####getMoves(fromNodes, depth)
The function should returns a [map][map] where the key is a value from the array __fromNodes__ and the value is an array of nodes that can be reached from the given key.
<br/>The function may also return a [promise][bluebird] that once resolved, will return the above [map][map]
<br/>The function may also return a [promise][bluebird] that once resolved, will return the above [map][map].

@@ -57,13 +56,13 @@ E.g. For the following graph:

new Map([
[1, [2,3]],
[2, [3]],
[3, []]
[1, [2,3]],
[2, [3]],
[3, []]
])
```
#### isGoal(node)
The function should return a boolean value (true/false) where `true` means the given `node` is the "finish" node otherwise, `false`
<br/>The function may also return a [promise][bluebird] that once resolved, will return `true/false`.
####isGoal(node)
The function should return a boolean value `true`/`false`. Where `true` means the given `node` is the "finish" node, otherwise `false`.
<br/>The function may also return a [promise][bluebird] that once resolved, will return `true`/`false`.
#### find()
####find()
This function returns a promise. The promise, once resolved, will return the shorted BFS path (if exists) or null if such path does not exist.

@@ -79,5 +78,8 @@

```
Calling `find()` where start is `1` and goal is `5`, will a promise that once resolved, it returns `[1, 2, 4, 5]`.
<br/>Calling `find()` where start is `1` and goal is `-1`, will a promise that once resolved, it returns `null`.
Calling `find()` where start node is `1` and goal node is `5`, will return a promise that once resolved, it will returns `[1, 2, 4, 5]`.
<br/>Calling `find()` where start node is `1` and goal node is `-1`, will return a promise that once resolved, it will returns `null`.
## License
MIT
[npm-image]: https://img.shields.io/npm/v/bfs-as-promised.svg?style=flat-square

@@ -84,0 +86,0 @@ [npm-url]: https://npmjs.org/package/bfs-as-promised

Sorry, the diff of this file is not supported yet

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