Socket
Book a DemoInstallSign in
Socket

@klippersubs/bfs

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

@klippersubs/bfs

General purpose BFS implementation.

2.1.7
latest
Source
npmnpm
Version published
Weekly downloads
2
-50%
Maintainers
1
Weekly downloads
 
Created
Source

@klippersubs/bfs

Travis CI NPM version

General purpose BFS implementation.

yarn add @klippersubs/bfs
import { flatten } from '@klippersubs/bfs';

const en = { name: 'en', fallback: [] };
const ru = { name: 'ru', fallback: [en] };
const be = { name: 'be', fallback: [ru] };
const uk = { name: 'uk', fallback: [be, ru] };

be.fallback = [ru, uk];

const beTarask = { name: 'be-tarask', fallback: [be, uk] };

const lookupList = flatten(null, beTarask, (_, language) => language.fallback);

console.log(lookupList);
// → Set {
//     { name: 'be-tarask', fallback: [ [Object], [Object] ] },
//     { name: 'be', fallback: [ [Object], [Object] ] },
//     { name: 'uk', fallback: [ [Object], [Object] ] },
//     { name: 'ru', fallback: [ [Object] ] },
//     { name: 'en', fallback: [] } }

Exported API

Type export ChildrenGetter

Returns children of the given vertex in the given graph.

Generic params:

  • Graph — graph type.
  • Vertex — vertex type.

Params:

  • graph: Graph — graph containing the vertex.
  • vertex: Vertex — vertex in the graph.

Return value:

  • Array<Node> — flat array of vertices.

Export flatten

Flattens cyclic graph starting from root vertex.

Generic params:

  • Graph — graph type.
  • Vertex — vertex type.

Params:

  • graph: Graph — graph or forest.
  • root: Vertex — vertex to start search.
  • getChildren: ChildrenGetter<Graph, Vertex> — returns children of the given vertex.

Return value:

  • Set<Vertex> — flat set of vertices.

License

MIT

Keywords

bfs-algorithm

FAQs

Package last updated on 06 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.