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 🙏

© 2025 – Pkg Stats / Ryan Hefner

universql

v0.3.9

Published

Universal database query language

Downloads

22

Readme

UniversQL

A JavaScript implementation of the UniversQL spec.

Installation

$ npm install universql

Example

var UniversQL = require("universql");
UniversQL.addAdapter(require("universql-json"));

API

UniversQL
.adapters
.addAdapterUniversQL
.removeAdapterUniversQL
.getDefaultAdapterAdapter
.setDefaultAdapterUniversQL
.templateRE
.getAdapter([name])Adapter
.setAdapter(The)UniversQL
.compile([name], [recompile])*
.translate([name], [context])*
.run([name], data, [context])*

UniversQL

The UniversQL class: parses a query string and attaches to this.query.

| Param | Type | Description | | --- | --- | --- | | queryString | String | The query string to parse. |

UniversQL.adapters

Adapters allow conversion between a UniversQL JSON-object, and their specific language. An Adapter should contain name, translate and optionally run.

The prototypes share a common adapter list. Furthermore, we make #addAdapter both an Instance and Static method (to facilitate additions).

UniversQL.addAdapter ⇒ UniversQL

Adds an adapter: sets as default if no current default.

Returns: UniversQL - The instance (for chaining).

| Param | Type | Description | | --- | --- | --- | | adapter | Adapter | The adapter to be added. |

UniversQL.removeAdapter ⇒ UniversQL

Removes an adapter.

Returns: UniversQL - The adapter that was removed.

| Param | Type | Description | | --- | --- | --- | | adapter | Adapter | The adapter to be removed. |

UniversQL.getDefaultAdapter ⇒ Adapter

Gets the default adapter.

Returns: Adapter - The default adapter.

UniversQL.setDefaultAdapter ⇒ UniversQL

Sets the default adapter.

Returns: UniversQL - The instance (for chaining).

| Param | Type | Description | | --- | --- | --- | | The | Adapter | String | default adapter (or name of installed adapter). |

UniversQL.templateRE

Basic templating, inspired by doT.js. Only includes basic interpolation.

UniversQL.getAdapter([name]) ⇒ Adapter

Gets the adapter.

Returns: Adapter - The adapter.

| Param | Type | Description | | --- | --- | --- | | [name] | String | Optional name of adapter to get. |

UniversQL.setAdapter(The) ⇒ UniversQL

Sets the adapter.

Returns: UniversQL - The instance (for chaining).

| Param | Type | Description | | --- | --- | --- | | The | Adapter | String | adapter (or name of installed adapter). |

UniversQL.compile([name], [recompile]) ⇒ *

Compiles the query into another query language. Stores into compiled.

Returns: * - Translated form of query.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [name] | String | | Name of the adapter to use (falls back to default). | | [recompile] | Boolean | false | If true, forces re-translation. |

UniversQL.translate([name], [context]) ⇒ *

Translate query using context (and compiles if necessary).

Returns: * - Query with templates compiled.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [name] | String | | Name of the adapter to use (falls back to default). | | [context] | Object | {} | Context for templating. |

UniversQL.run([name], data, [context]) ⇒ *

Runs query (translates, templatizes and compiles if necessary).

Returns: * - Query with templates compiled.

| Param | Type | Default | Description | | --- | --- | --- | --- | | [name] | String | | Name of the adapter to use (falls back to default). | | data | Array | | The data on which to run the query. | | [context] | Object | {} | Context for templating. |

createTemplate(str, pattern) ⇒ function

Creates a template function (that renders when called with context).

Returns: function - Template function: fn(context)

| Param | Type | Description | | --- | --- | --- | | str | String | The template to precompile. | | pattern | RegExp | The template pattern to replace. |

templater(data, fn)

Runs data through template engine, then calls fn with results.

| Param | Type | Description | | --- | --- | --- | | data | * | The data to preprocess. | | fn | function | The subsequent function to call. |

License

MIT Licensed