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

ssb-subset-ql

v1.0.1

Published

Utility library to parse, validate, and compare ssb-ql-0 and ssb-ql-1

Downloads

205

Readme

ssb-subset-ql

Utility library to parse, validate, and compare ssb-ql-0 and ssb-ql-1 queries needed for subset replication and index feeds in SSB.

Installation

Prerequisites:

  • Requires Node.js 10 or higher
npm install --save ssb-subset-ql

To use this library, import its utilities like this:

const { QL0 } = require('ssb-subset-ql')

API

QL0

validate(query)

Takes a query (string or object) and checks that it satisfies the ssb-ql-0 rules. If something is wrong, it throws an error. Otherwise it returns undefined.

parse(query)

Takes a ssb-ql-0 query (an object or JSON as a string), validates it, and parses it (if necessary) to return a query object. If anything went wrong during validation, returns null.

toOperator(query[, dedicated])

Takes a ssb-ql-0 query (an object or JSON as a string), validates it, parses it (if necessary) and then converts the query to an ssb-db2 operator which can be inserted inside an ssb-db2 where(). If anything went wrong during validation, it throws an error.

A second optional argument, dedicated, is a boolean that indicates whether the underlying database should use dedicated index files for type and author. By default, this is false.

stringify(query)

Takes a ssb-ql-0 query (an object), validates it, and stringifies it into a canonical (stable, unaffected by how the object was created) JSON string. Returns the JSON string. If anything went wrong during validation, it throws an error.

isEquals(query1, query2)

Takes two ssb-ql-0 query objects, parses both of them, and checks that they are equivalent.

QL1

validate(query)

Takes a query (string or object) and checks that it satisfies the ssb-ql-1 rules. If something is wrong, it throws an error. Otherwise it returns undefined.

parse(query)

Takes a ssb-ql-1 query (an object or JSON as a string), and parses it (if necessary) to return a query object. If anything went wrong during validation, returns null.

toOperator(query[, dedicated])

Takes a ssb-ql-1 query (an object), and converts it to an ssb-db2 operator which can be inserted inside an ssb-db2 where().

A second optional argument, dedicated, is a boolean indicating whether the underlying database should use dedicated index files. By default, it's false.

stringify(query)

Takes a ssb-ql-1 query (an object), and stringifies it as a JSON string.

~~isEquals(query1, query2)~~

Not yet supported. Will always throw an error if you use it.

License

LGPL-3.0