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

net-to-img

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

net-to-img - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

12

index.d.ts

@@ -0,1 +1,3 @@

import Graph from "graphology-types";
export type NetToImgOptions = {

@@ -11,3 +13,3 @@ width: number;

export interface NetToImgParams {
export interface NetToImgParamsFromPaths {
sourcePath: string;

@@ -18,2 +20,10 @@ destPath: string;

export interface NetToImgParamsFromGraph {
graph: Graph;
destPath: string;
options?: NetToImgOptions;
}
export type NetToImgParams = NetToImgParamsFromPaths | NetToImgParamsFromGraph;
export default function netToImg(

@@ -20,0 +30,0 @@ params: NetToImgParams,

28

index.js
// Deps imports:
const seedrandom = require("seedrandom");
const isGraph = require("graphology-utils/is-graph");

@@ -14,4 +15,9 @@ // Local imports:

function validateParams(params) {
if (!params.sourcePath)
throw new Error("net-to-img: expecting a `sourcePath`!");
if (params.graph) {
if (!isGraph(params.graph))
throw new Error("net-to-img: expecting a valid graphology instance!");
} else {
if (!params.sourcePath)
throw new Error("net-to-img: expecting a `sourcePath`!");
}

@@ -39,6 +45,3 @@ if (!params.destPath) throw new Error("net-to-img: expecting a `destPath`!");

// Actual program:
loadGraphFn({ sourcePath }, function (err, graph) {
if (err) throw new Error(err);
function processGraph(graph) {
// Randomness and seeds:

@@ -84,3 +87,14 @@ if (seed) {

);
});
}
// Actual program:
if (params.graph) {
processGraph(params.graph);
} else {
loadGraphFn({ sourcePath }, function (err, graph) {
if (err) throw new Error(err);
processGraph(graph);
});
}
};
{
"name": "net-to-img",
"version": "0.3.0",
"version": "0.4.0",
"description": "A CLI tool and library to quickly render a network's topology as an image",

@@ -30,2 +30,4 @@ "main": "index.js",

"graphology-svg": "^0.1.0",
"graphology-types": "^0.16.0",
"graphology-utils": "^1.7.0",
"iwanthue": "^1.4.0",

@@ -36,4 +38,5 @@ "seedrandom": "^3.0.5",

"devDependencies": {
"graphology-generators": "^0.10.1",
"prettier": "^2.0.2"
}
}

@@ -30,14 +30,30 @@ # net-to-img

```js
const netToImg = require('net-to-img');
const netToImg = require("net-to-img");
netToImg({
sourcePath: 'path/to/graph/file',
destPath: 'path/to/output/image',
options: {
layout: false
netToImg(
{
sourcePath: "path/to/graph/file",
destPath: "path/to/output/image",
options: {
layout: false,
},
},
(err) => {
if (!err) console.log("Everything went well!");
}
}, err => {
if (!err)
console.log('Everything went well!');
});
);
// To directly pass a graph instance
netToImg(
{
graph: myGraph,
destPath: "path/to/output/image",
options: {
layout: false,
},
},
(err) => {
if (!err) console.log("Everything went well!");
}
);
```

@@ -59,2 +75,6 @@

### v0.4.0
- Adding possibility to directly pass a `graphology` instance
### v0.3.0

@@ -61,0 +81,0 @@

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