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

graft-db

v0.0.22

Published

```javascript import { MemStore, Repository, BaseTypes } from 'graft-db';

Downloads

64

Readme

Working with state

import { MemStore, Repository, BaseTypes } from 'graft-db';

// create the store where things get persisted
const store = new MemStore();

// create a repository (one repository can have many tags/branches)
let r = new Repository({ store, id: 'myrepo' });

// create/fetch a branch and name
let master = r.latest().checkout('master');
master = master.set('n1', {type: BaseTypes.Node});
master = master.set('n2', {type: BaseTypes.Node});

// update the 'master' tag to point to this state
master = master.commit();

// fetch new metadata into r
r = r.latest();

// checkout another copy of the master branch
let wip = r.latest().checkout('master');
wip.key() === master.key(); // => true

// change wip and commit to master
wip = wip.set('n100', {type: BaseTypes.Node});
wip = wip.commit();

// continue working on master
// and now try to commit
master = master.set('n3', {type: BaseTypes.Node});
master = master.commit(); // fail 'needs rebase' since upstream is ahead

// fix it by pulling latest
master = master.pull();

// or fix it by rebasing from wip
master = master.rebase(wip);

// now can commit
master.commit();

Building a graph (low level)

// create a node to represent a "Person" type
master = master.set('uuid-person', {type: BaseTypes.Node, name: 'Person'});

// create a property to hold the person's name
master = master.set('uuid-person-name', {type: BaseTypes.String, name: 'name', nullable: true});

// create an "instance" of a person node
master = master.set('uuid-jeff', {type: 'uuid-person'});

// store a name
master = master.setString('uuid-jeff-name', 'jeff');
master = master.set('uuid-jeff-name', {type: 'uuid-person-name', value: {
	type: ValueKeyTypes.data,
	id: 'uuid-jeff-name',
}});

Build a graph (high level) - DEPRECATED

// create a node to represent a "Person" type
master = master.setType({
	name: 'Person',
	properties: {
		name: { type: BaseTypes.String, },
	}
});

// create an "instance" of a person node
master = master.setNode({
	type: 'Person',
	values: {
		name: 'jeff',
	}
});

Querying the graph

let result;
[result, mastelr] = master.query(`{
	node(id: 'uuid-jeff') {
		...on Person {
			name
		}
	}
}`); // => {data: { node: { name: 'jeff' } } }