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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gud/json-store

v0.0.2

Published

A TypeScript-first JSON key-value store with Zod schema validation.

Downloads

4

Readme

Gud JSON Store

GitHub NPM
Version License:
Apache-2.0

A TypeScript-first JSON key-value store with Zod schema validation.

✨ Features

  • Type-safe - Full TypeScript support with Zod schema validation
  • File-based persistence - Automatically saves data to JSON files
  • Schema validation - Ensure data integrity with Zod schemas
  • Always up-to-date - Reads directly from file to ensure fresh data
  • Auto-recovery - Backs up corrupted files and resets to defaults
  • Simple API - Intuitive get/set interface with key-value operations
  • Zero dependencies - Only requires Zod as a peer dependency
  • Project-aware - Automatically detects project root for default storage

Installing

npm install @gud/json-store zod

Quick Start

import { JsonStore } from '@gud/json-store';
import { z } from 'zod';

// Create a simple store
const store = new JsonStore();

// Set some values
store.set('name', 'John Doe');
store.set('age', 30);

// Get values
const name = store.get('name'); // "John Doe"
const data = store.get('name', 'age'); // { name: "John Doe", age: 30 }

// With schema validation
const userSchema = z.object({
  name: z.string(),
  age: z.number(),
  email: z.string().email().optional(),
});

const userStore = new JsonStore({
  name: 'users',
  schema: userSchema,
  defaults: {
    name: '',
    age: 0,
  },
});

userStore.set('email', '[email protected]');

API Reference

JsonStore Class

Properties

  • path: string - Full path to the JSON file
  • schema: z.ZodObject - The Zod schema used for validation
  • defaults: TData - Default values for the store

Methods

read(): TData

Read and return all data from the store.

set(key, value) / set(values)

Set a single key-value pair or multiple values at once.

store.set('key', 'value');
store.set({ key1: 'value1', key2: 'value2' });
get(key) / get(...keys)

Get a single value or multiple values by key(s).

const value = store.get('key');
const values = store.get('key1', 'key2'); // Returns object
has(...keys): boolean

Check if all specified keys exist in the store.

if (store.has('name', 'email')) {
  // Both keys exist
}
delete(...keys): void

Delete one or more keys from the store.

store.delete('key1', 'key2');
reset(): TData

Reset the store to its default values.

rm(): void

Delete the JSON file from disk.

getProjectRoot() Util

Get the path to the nearest app root directory, determined by the presence of a package.json file.

import { getProjectRoot } from '@gud/json-store';
import { join } from 'node:path';

const rootPath = getProjectRoot();
const packageJsonPath = join(rootPath, 'package.json');
console.log(`package.json path: ${packageJsonPath}`);

getOSConfigDir() Util

Get the path to an app specific config directory based on operating system standards.

import { getOSConfigDir } from '@gud/json-store';

const configDir = getOSConfigDir('app-name');
console.log(`Config directory: ${configDir}`);
// e.g. ~/Library/Application Support/app-name on macOS

Error Handling

JsonStore automatically handles common errors:

  • Corrupted JSON: Creates a backup and resets to defaults
  • Invalid schema: Throws validation errors with detailed messages
  • Missing directories: Automatically creates parent directories
  • Non-serializable values: Throws TypeError for functions, symbols, etc.

License

Apache-2.0