npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jay-gee-eff-for-web

v0.2.2

Published

JGF - JSON Graph Format helper module for usage in the web

Downloads

175

Readme

Run tests Scrutinizer Code Quality Maintainability Test Coverage

jay-gee-eff-for-web

JGF - A JSON Graph Format npm module to be used in the web (i.e. does not require nodejs to run). For more information about JSON Graph Format head over to jsongraph/json-graph-specification.

I will not include a list of features here since this package aims to completely fulfill the specification linked above.

If you want to learn more about graphs or are not sure what a graph is and whether you may need it or not, have a look at the graph theory wikipedia article.

Installation

with yarn

yarn add jay-gee-eff-for-web

or with npm

npm install jay-gee-eff-for-web

Usage

This package is following semantic versioning 2.0.0.

API Docs

You can find an API documentation over at arsn.github.io/jay-gee-eff-for-web-docs. This is aiming to describe all classes and methods in as much detail as possible.

Example code

const { JgfNode, JgfEdge, JgfGraph, JgfJsonDecorator } = require('../index');

(() => {
    console.log('Building the NBA Jgf Graph...');
    let graph = new JgfGraph('sports', 'NBA Demo Graph');

    const node1Id = 'lebron-james#2544';
    const node1Label = 'LeBron James';
    const metadata1 = {
        type: 'NBA Player',
    };

    const node2Id = 'la-lakers#1610616839';
    const node2Label = 'Los Angeles Lakers';
    const metadata2 = {
        type: 'NBA Team',
    };

    const playerContractRelation = 'Plays for';

    console.log('Adding two nodes...');
    graph.addNode(new JgfNode(node1Id, node1Label, metadata1));
    graph.addNode(new JgfNode(node2Id, node2Label, metadata2));

    console.log('Adding an edge...');
    graph.addEdge(new JgfEdge(node1Id, node2Id, playerContractRelation));

    console.log('Graph nodes:');
    for (let node of graph.nodes) {
        console.log(`\t${node.label} {${node.metadata.type}}`);
    }

    console.log('Graph edges:');
    for (let edge of graph.edges) {
        console.log(`\t${edge.source} (->${edge.relation}->) ${edge.target}`);
    }

    console.log('Full JSON representation:');
    console.log(JSON.stringify(JgfJsonDecorator.toJson(graph)));

    console.log('-- DONE --');
})();

Expected console output

Building the NBA JGF Graph...
Adding two nodes...
Adding an edge...
Graph nodes:
	LeBron James {NBA Player}
	Los Angeles Lakers {NBA Team}
Graph edges:
	lebron-james#2544 (->Plays for->) la-lakers#1610616839
Full JSON representation:
	[... see next headline in README.md ...]
-- DONE --

The JSON output from example above

{
  "graph": {
    "type": "sports",
    "label": "NBA Demo Graph",
    "directed": true,
    "nodes": [
      {
        "id": "lebron-james#2544",
        "label": "LeBron James",
        "metadata": {
          "type": "NBA Player"
        }
      },
      {
        "id": "la-lakers#1610616839",
        "label": "Los Angeles Lakers",
        "metadata": {
          "type": "NBA Team"
        }
      }
    ],
    "edges": [
      {
        "source": "lebron-james#2544",
        "target": "la-lakers#1610616839",
        "relation": "Plays for",
        "directed": true
      }
    ]
  }
}

References

Credits

Big thanks to bigman73 for his original package which served as a template for this one and brought the idea.

Alternatives

  • jay-gee-eff - JGF package with local file accessibility, you want to use this if you plan to use it on the server side.

JGF specification

http://jsongraphformat.info/

Test examples

Source: https://github.com/jsongraph/json-graph-specification/tree/master/examples