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

@crikey/json-private-pointer

v0.0.2

Published

Functions for handling JSON pointers [rfc6901](https://www.rfc-editor.org/rfc/rfc6901.html) and [relative-json-pointer](https://datatracker.ietf.org/doc/html/draft-luff-relative-json-pointer-00), with an additional extension for marking path segments as "

Downloads

2

Readme

@crikey/json-private-pointer

Functions for handling JSON pointers rfc6901 and relative-json-pointer, with an additional extension for marking path segments as "public" or "private".

See @crikey/json-private-pointer for full documentation.

API

Types

Contains types used to represent JSON pointers and segments

Guards

Contains typescript guards for identifying type information.

  • is_pointer Returns true if value is a Pointer
  • is_absolute Returns true if value is an AbsolutePointer
  • is_relative Returns true if value is a RelativePointer

Error classes

Classes used when throwing errors

  • PointerDecodingError Error class thrown for pointer decoding errors
  • PointerEncodingError Error class thrown for pointer encoding errors

Creation

Functions used for creating paths from their constituent parts

  • pointer Create a Pointer from a series of decoded segments

  • absolute Create an AbsolutePointer from a series of decoded segments

  • relative Create a RelativePointer from a relative number and a series of decoded segments

  • pointer_encoded Create a Pointer from an optional relative number and a series of encoded segments

  • absolute_encoded Create an AbsolutePointer from a series of encoded segments

  • relative_encoded Create a RelativePointer from a relative number and a series of encoded segments

Joining

Combining pointer components and segments

  • join_pointer Join two Pointers together

  • join_segments Append decoded segments onto an existing Pointer

  • join_encoded_segments Append encoded segments onto an existing Pointer

Encoding

Encode and decode path segments

  • segment_encode Encode a given string segment
  • segment_decode Decode a given string segment

Splitting

Split paths into their constituent components/segments

  • split Split a Pointer into its constituent parts, decoding each segment

  • split_absolute Split a AbsolutePointer into its constituent parts, decoding each segment

  • split_relative Split a RelativePointer into its constituent parts, decoding each segment

  • split_encoded Split a Pointer into its constituent parts, leaving segments encoded

  • split_encoded_absolute Split a AbsolutePointer into its constituent parts, leaving segments encoded

  • split_encoded_relative Split a RelativePointer into its constituent parts, leaving segments encoded

Installation

# pnpm
$ pnpm add @crikey/json-private-pointer

# npm
$ npm add @crikey/json-private-pointer

# yarn
$ yarn add @crikey/json-private-pointer

Example Usage

Guards

console.log(is_pointer('xyz')); // false
console.log(is_pointer('/xyz')); // true
console.log(is_pointer('123/xyz')); // true
console.log(is_absolute('123/xyz')); // false
console.log(is_relative('123/xyz')); // true

Creating

console.log(pointer('x',[true, 'y'], [false, 'z'])); // '/x/~3y/z'
console.log(pointer('~/')); // '/~0~1'
console.log(pointer(undefined,'x','y','z')); // '/x/y/z'
console.log(pointer(123,'x','y','z')); // '123/x/y/z'
console.log(relative(123,'x','y','z')); // '123/x/y/z'

Joining

console.log(join_pointer('/a/b/c', '/x/y/z')); // '/x/y/z'
console.log(join_pointer('/a/b/c', '1/x/y/z')); // '/a/b/x/y/z'
console.log(join_segments('/a/b/c', 'x', [true, 'y'], 'z')); // '/a/b/c/x/~3y/z'
console.log(join_segments('/a/b/c', '~')); // '/a/b/c/~0'

Splitting

console.log(split('/a/~3b/c')); // { segments: [[false, 'a'], [true, 'b'], [false, 'c']] }
console.log(split('123/a/~3b/c')); // { relative: 123, segments: [false, 'a'], [true, 'b'], [false, 'c'] }