Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Functional / TypeScript implementation of Graph with 100% unit test coverage! All methods are pure and the data structures are immutable. It has build-in functional BFS.
Functional / TypeScript implementation of Graph with 100% unit test coverage! All methods are pure and the data structures are immutable.
It has build-in functional BFS.
It uses https://github.com/ramda/ramda
$ npm install fgraph --save
import * as R from 'ramda'
import Graph from 'fgraph'
const result = R.pipe(
Graph.newGraph,
Graph.addVertices([
{ name: 'New York' },
{ name: 'San Francisco' }
]),
Graph.addEdges([
{
link: ['New York', 'San Francisco'],
distance: 2902,
unit: 'miles'
}
]),
Graph.BFS('New York')
)();
/**
* returns:
* [
* { name: 'New York' },
* { name: 'San Francisco' }
* ]
*/
let myGraph = Graph.newGraph();
myGraph = addVertices([
{name: 'New-York'},
{name: 'San Francisco'}
], myGraph);
myGraph = addEdges([
{
link: ['New York', 'San Francisco'],
distance: 2902,
unit: 'miles'
}
], myGraph);
const nodeList = Graph.BFS('New York', myGraph);
/**
* nodeList:
* [
* { name: 'New York' },
* { name: 'San Francisco' }
* ]
*/
Graph
✓ newGraph
✓ addVertex
✓ addVertices
✓ addEdge
✓ addEdges
✓ getVertexHash
✓ getEdgeHash
✓ hasVertex
✓ hasEdge
✓ hasVertexByHash
✓ hasEdgeByHash
✓ getVertexByHash
✓ getEdgeByHash
✓ getVertices
✓ getEdges
✓ removeEdgesAssociatedWithVertexHash
✓ removeVertexByHash
✓ removeEdgeByHash
✓ getNeighborVerticesFromVertexHash
✓ getNeightborEdgesFromVertexHash
✓ BFS
interface IEdge {
link: Array<String>
}
interface IVertex {
name: String
}
interface IGraph {
vertices: Array<IVertex>,
edges: Array<IEdge>,
}
newGraph :: () -> IGraph
Generates new empty graph
getVertexHash :: IVertex -> String
Hashing function for IVertex. Can be customized.
getEdgeHash :: IEdge -> String
Hashing function for IEdge. Can be customized.
edgeHash :: () -> Array<IVertex>
Hashing function for IVertex. Can be customized.
getEdges :: IGraph -> Array<IEdge>
Returns a list of all edges in a graph
addVertex :: IVertex -> IGraph -> IGraph
Adds Vertex to the graph
addVertices :: Array<IVertex> -> IGraph -> IGraph
Adds multiple Vertices to the graph
getVertexByHash :: String -> IGraph -> IVertex
Return Vertex by Hash
addEdge :: IEdge -> IGraph -> IGraph
Adds edge to the graph
addEdges :: Array<IEdge> -> IGraph -> IGraph
Adds multiple Edges to the graph
getEdgeByHash :: String -> IGraph -> IEdge
Return Edge by Hash
hasVertexByHash :: String -> IGraph -> Boolean
Checks if vertex's hash exists in the graph
hasVertex :: IVertex -> IGraph -> Boolean
Checks if vertex exists in Graph
hasEdgeByHash :: String -> IGraph -> Boolean
Checks if edge's hash exists in the graph
hasEdge :: IEdge -> IGraph -> Boolean
Checks if edge exists in the graph
removeVertexByHash :: String -> IGraph -> IGraph
Removes vertex and all edges associated with it
removeEdgeByHash :: String -> IGraph -> IGraph
Removes edge from graph
getNeightborEdgesFromVertexHash :: String -> IGraph -> Array<IEdge>
Get all neightboring Edges from Vertex by Vertex Hash
getNeighborVerticesFromVertexHash :: String -> IGraph -> Array<IVertex>
Get all neightboring Vertices From Vertex by Vertex hash
BFS :: String -> IGraph -> Array<IVertex>
Breadth First Search with starting node
All PRs and feedback is wellcome!
npm test
npm run dev
Alex Kolarski (aleks.rk@gmail.com)
(The MIT License)
Copyright (c) 2019 Alex Kolarski <aleks.rk@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Functional / TypeScript implementation of Graph with 100% unit test coverage! All methods are pure and the data structures are immutable. It has build-in functional BFS.
The npm package fgraph receives a total of 0 weekly downloads. As such, fgraph popularity was classified as not popular.
We found that fgraph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.