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

@jdw/jst

v2.0.0-beta.15

Published

A json schema toolkit.

Readme

JST - JSON Schema Toolkit

A library for working with json schema. Build Status

JST is a robust and modular library for working with json schema and provides practical utilities for some of the many specifications surrounding this standard such as json references and json pointers.

For exhaustive documentation please see the project homepage homepage. For a quick overview of jst's functionality and capabilities see below.

Quick-start

Install JST to your project:

npm i --save @jdw/jst

Import and begin using the functions (ES6):

import { dereference, get, set, isPointer } from '@jdw/jst';

API

get

Retrieve a value from an object as referenced by a json pointer.

  • get(object: Object, pointer: String) => any

Usage

import { get } from '@jdw/jst';

const data = {
    foo: 99
};

get(data, '#/foo'); // 99

set

Sets a value on an object as referenced by a json pointer;

  • set(object: Object, pointer: String, value: any) => void

Usage

import { set } from '@jdw/jst';

const data = {
    foo: 99
};

set(data, '#/foo', 77);

console.log(data); // { foo: 77 }

isPointer

Performs a logical test on a string to determine if it is a json pointer.

  • isPointer(subject: string) => boolean

Usage

import { isPointer } from '@jdw/jst';

console.log(isPointer('#/foo/0/blah')); // true
console.log(isPointer('#'));            // true
console.log(isPointer('some string'));  // false

dereference

Dereferences a schema according to the json references specification.

  • dereference(schema: Object)
  • dereference(schema: Object, resolve: (id) => Object)

Usage

In it's most basic form dereference takes a schema without any external references as an argument and resolves any of it's internal pointers.

import { dereference } from '@jdw/jst';

const schema = {
    'car': {
        '#/def/car'
    },
    'def': {
        'car': {
            'type': 'string',
            'enum': ['ferrari', 'mercedes', 'bmw', 'vw']
        }
    }
};

// a resolver function is not required when de-referencing schema without external
// uri references
console.log( dereference(schema) );

This dereferences to:

{
    'car': {
        'type': 'string',
        'enum': ['ferrari', 'mercedes', 'bmw', 'vw']
    }
}

The dereference function may be injected with a schema resolver function as its second argument. The resolve function is expected to take a schema id (uri reference) as it's input and return that schema as an object literal. This allows you to flexible in how you provision your schema be it over the wire or storing it in memory. If the resolve function cannot find the schema it is expected to throw an error.

The following is an example of using an AJV instance as supplier for a resolve function.

dereference(schema, (id) => {
    return ajv.getSchema(id).schema
});

Contributing

Contributions to JST are most welcome, here we outline how to get setup for development.

Requirements

  • NodeJS >= 6

Setup

Fork and clone this project then navigate to the project directory. Open up a terminal and run the following commands and execute npm i to install the projects development dependencies, try the following scripts out to get started - you can find more in package.json.

  • npm build: build all source code and documentation
  • npm test: run all unit test.
  • npm benchmark: run the benchmark suite (requires npm build to have been run)

Make your changes and commit your code. When you are ready, send a pull request to this repository.