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

@gistbase/gistbase

v1.3.2

Published

Key value data storage backed by GitHub Gists.

Downloads

23

Readme

Gistbase

CI

A key-value datastore backed by GitHub Gists.

Usage

npm install @gistbase/gistbase

GistbaseLite

GistbaseLite uses the GitHub Gists API only to perform operations. This comes with the following limitations.

  • Handles up to 299 keys. Adding more than 299 keys may cause getKey to fail due to truncation by the API.
  • Accepts up to one megabyte of content for a key's value.
import {GistbaseLite} from '@gistbase/gistbase'

token is a gist scoped GitHub PAT.

// Create a Gistbase
const gistbase = await GistbaseLite.create(token)

// Create a Gistbase instance from an existing Gist ID
const gistbase = await GistbaseLite.fromId(id, token)

// Put a key value pair
await gistbase.putKey('foo', 'bar')

// Get the value of a key
const {value: foo} = await gistbase.getKey('foo')

// Retry getting a key until it exists or the timeout expires
const {value: baz} = await gistbase.getKey('baz', {timeoutSeconds: 360})

// Delete a key
await gistbase.deleteKey('foo')

// Re-fetch and cache the underlying Gist
await gistbase.fetch()

// Delete the Gistbase
await gistbase.delete()

Gistbase

Gistbase uses a combination of the GitHub Gists API and a git client to perform operations. It requires a filesystem path to cache the underlying Gist.

import {Gistbase} from '@gistbase/gistbase'

token is a gist scoped GitHub PAT.

// Create a Gistbase
const gistbase = await Gistbase.create('/path/to/cache/directory', token)

// Create a Gistbase instance from an existing Gist ID
const gistbase = await Gistbase.fromId(id, '/path/to/cache/directory', token)

// Put a key value pair
await gistbase.putKey('foo', 'bar')

// Get the value of a key
const {value: foo} = await gistbase.getKey('foo')

// Put a key file pair
await gistbase.putFile('foo', '/path/to/value')

// Get the filepath of a key
const {filepath: foo} = await gistbase.getFile('foo')

// Retry getting a key until it exists or the timeout expires
const {value: baz} = await gistbase.getKey('baz', {timeoutSeconds: 360})

// Delete a key
await gistbase.deleteKey('foo')

// Re-fetch and cache the underlying Gist
await gistbase.fetch()

// Start a transaction
gistbase.startTransaction()

// End a transaction applying all put and delete operations
await gistbase.endTransaction()

// Delete the Gistbase
await gistbase.delete()

Caveats

The following usage caveats apply to both GistbaseLite and Gistbase.

  • Gistbase methods are not synchronised and are unsuitable for multithreaded use.
  • Multiple clients may access the same Gistbase. Use getKey() with retryOptions to wait for a key to exist. Or, call fetch() to update the client's cache when changes have been made to the underlying Gist.

License

MIT