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

jq-in-the-browser

v0.7.2

Published

jq-compatible query language for the web

Downloads

186

Readme

jq-in-the-browser

jq-in-the-browser is a JavaScript port of jq. Try it online

Instead of processing serialized data, jq-in-the-browser processes JavaScript objects. It is written from scratch and is relatively small. (~33 kB, ~6.1 kB gzipped)

Install

npm install --save jq-in-the-browser

Usage

import jq from 'jq-in-the-browser'

const query = jq('{"names": [.[] | .name]}')

query([
  {"name": "Mary", "age": 22},
  {"name": "Rupert", "age": 29},
  {"name": "Jane", "age": 11},
  {"name": "John", "age": 42}
])

Output:

{
  "names": [
    "Mary",
    "Rupert",
    "Jane",
    "John"
  ]
}

Comparison with alternatives

jq-web

  • jq-web is an emcripten port of jq, thus it implements all of its features
  • ... but it's also too big for many purposes (in the megabytes)
  • jq-in-the-browser is written from scratch, but is more limited in features
  • ... and also much much smaller :-)

node-jq

  • node-jq is great, but it doesn't work in the browser.

something else?

If you know an alternative, feel free to create a pull request. :-)

Supported features

Feature | Example --- | --- Identity|., . Array Index|.[0], .[1 ], .[-1], .[ 1][0], .[1][1].x, .[1][1].x[0], .[ -1 ] Object Identifier-Index|.foo, .bar, .bar.x, .foo[1] Generic Object Index|.["foo"], .["bar"].x, .bar[ "y"], .["2bar"], .["a b" ] Pipe|.a \| .b, .a\|.b Parentheses|( .a), ((.a)), (-1 ), (-5.5), (.4), (. \| .) Addition (numbers)|1 + 1, .a + [.b][0], .b + .a, 3 + 4.1 + .a, 3 + (-3) Subtraction (numbers)|.a - .b, .b - .a, 4- 3, -3 -(4) Multiplication (numbers)|1 * 1, .a * [.b][0], .b * .a, 3 * 4.1 * .a, 3 * (-.3) Modulo (numbers)|1 % 1, .a % [.b][0], .b % .a, 3 % 4 % .a Division (numbers)|.a / .b, .b / .a, 4/ 3, -3/(4), -1.1 + (3 * (((.4 - .b) / .a) + .b)) Array Construction|[], [ ], [4], [ -6, [0]], [7 \| 4], [.], [. \| [6]], [5, 6] \| . Object Construction|{}, { }, {"foo": 6}, {"foo": 6, "bar": [5, 3]}, {"x": 3} \| {"y": .x}, {foo: "bar"}, {({"a": "b"} \| .a): true}, {"a": 4, "b": 3, "c": -1, "d": "f"} Integer literal|3, 6, -4, 0, 8 Float literal|.3, 6.0, -4.001, 3.14, 0.1 Boolean literal|true, false Double quote String literal|"true", "false", "foo", ["ba'r"] length|[] \| length, length keys|keys keys_unsorted|keys_unsorted to_entries|. \| to_entries from_entries|. \| from_entries reverse|. \| reverse map|map(.+1 ), . \| map( {foo: .}) map_values|map_values(.+1 ), . \| map_values( {foo: .}) with_entries|with_entries({key: .key, value: (2 * .value)}), with_entries({key: "a", value: (2 * .value)}) tonumber|tonumber tostring|tostring sort|sort, [4, 5, 6] \| sort sort_by|sort_by(-.), sort_by(1 + .), sort_by(1) join|join(", "), join(""), join(.[0]) Additive inverse|-(1 + 3), -(-1), .a \| -(.b), [--1] Array Construction|[], [4] Array/Object Value Iterator|.[], .[ ] Array/Object Value Iterator 2|.["foo"][], .foo[] Pipe|.[] \| ., .[] \| .name Stream as object value|{names: .[] \| .name}, {"names": .[] \| .name, "ages": .[] \| .age}, {"names": .[] \| .name, "x": 3}, {"names": 5.4, "x": .[] \| .age}, {names: 5.4, ages: .[] \| .age, ages2: .[] \| .id} Array/String slice|.[2:4], .[0:1]