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

nanograph

v1.0.3

Published

minimalistic in-memory graph for metadata management

Downloads

5

Readme

Nanograph

Minimalistic in-memory graph for metadata management. Allows to create directions graphs to store entities and connect them. Connections, called "edges" may also contain data.

Installation

Just run npm i nanograph. Types for Typescript are provided and must not be installed separately.

Usage

Initialisation

import { Nanograph } from 'nanograph';

const nano: Nanograph = new Nanograph();

Insert vertices and edges

const { _id: vertex1Id, error: error1 } = nano.createVertex('PERSON', { name: 'John Doe' });
const { _id: vertex2Id, error: error2 } = nano.createVertex('PERSON', { name: 'Jane Doe' });

const { _id: friendshipId } = nano.createEdge('FRIENDSHIP', vertex1Id, vertex2Id, {
    type: 'platonic', since: Date.now(),
});

Retrieve vertices and edges

Retrieve the first edge matching provided criteria. If an ID is given, it can simply be passed as string.

const vertex = nano.findVertices('PERSON', vertex1Id ).getFirst();			
const edge = nano.findEdges('FRIENDSHIP', { _id: { equals: friendshipId } }).getFirst();

For filtering, instead of an id, parameters can be provided. For this version, only equals is possible. Result of getAll is a list of vertices or edges

const vertex = nano.findVertices('PERSON', { name: { equals: 'John Doe' } }).getAll();
const edges = nano.findEdges('FRIENDSHIP', { type: { equals: 'platonic' } }).getAll();

Traversal is also possible using labels and properties to filter

const vertices = nano
    .findVertices('PERSON', { name: { equals: 'John Doe' } }) // a person called John Doe
    .over('CHILDOF').to('PERSON') // searching for John Does Parents
    .over('CHILDOF').to('PERSON', { gender: { equals: 'm' } }) // searching for their father, John Doe's grandfather
    .over('MARRIED').to('PERSON') // searching for his wife, John Doe's grandmother
    .getAll();

Update Entities

Both edges and vertices can be updated using update methods. Old values will be kept. If a value to update is already exiting, it will be overwritten.

nano.updateVertex(vertexId, { weight: 6000, hasFur: false });
nano.updateEdge(edgeId, { isShareHolder: true, holdings: 15 });

Delete Entities

Vertices and edges can be deleted by their id.

nano.deleteEdge(edgeId);
nano.deleteVertex(vertexid);