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

rhyme-lang

v0.0.4

Published

Rhyme: An Expressive Data-Centric Query Language

Downloads

2

Readme

Rhyme

CI Tests

Rhyme is an expressive declarative query language designed for high-level data manipulation, with a primary focus on querying nested structures (e.g., JSON, Tensors, etc.) and producing nested structures as a result.

Rhyme is still at very early stages of development and therefore expect rough edges and breaking changes. However, we are actively working on it and would love to hear your feedback.

Checkout our website rhyme-lang.github.io for more information.

Getting Started

To get started with the latest release of Rhyme in your node project, run the following command:

npm install rhyme-lang

You can then import the library (as you would any other node module) and start using it:

const { api } = require('rhyme-lang')

let data = [
    { key: "A", value: 10 },
    { key: "B", value: 20 },
    { key: "A", value: 30 }
]

let query = {
    total: api.sum("data.*.value"),
    "data.*.key": api.sum("data.*.value"),
}
let res = api.compile(query)({ data })
console.log("Result: " + JSON.stringify(res))

Visit documentation to get a glimpse of what Rhyme can do.

Using in the browser/frontend

Npm package rhyme-lang installed using above command is intended for use in nodejs projects. However, if you want to use Rhyme in the browser (especially the visualization features), you can use unpkg CDN to get the browser version of the library. Specifically, you can include the script from the following URL in your HTML file:

https://unpkg.com/rhyme-lang/umd/rhyme-lang.min.js

Shown below is a simple complete example HTML file:

<!DOCTYPE html>
<html>
    <head>
        <title>Rhyme Example</title>
        <meta charset="UTF-8">
    </head>
        <body>
            <h1>Rhyme Example</h1>
            <div id="root"></div>

            <script src="https://unpkg.com/rhyme-lang/umd/rhyme-lang.min.js"></script>

            <script>
                let api = rhyme.api
                let domParent = document.getElementById("root")
                let data = [{x:20,y:70},{x:40,y:30},{x:60,y:50},{x:80,y:60},{x:100,y:40}]
                let query = {
                    "$display": "select",
                    data: data
                }
                let res = api.query(query)
                api.display(res({}), domParent)
            </script>
        </body>
</html>

Development

Setup

Clone the repo and run npm install to install all the dependencies.

If you want to use the development version of the library you cloned in a different project, you can run npm link in the root directory of the repo and then run npm link rhyme-lang in your project directory.

Setup for running on browser

If you want to use the development version of the library in the browser, you can use webpack to build the browser version of the library. Use the following commands.

npm install webpack webpack-cli --save-dev
./node_modules/.bin/webpack

This will generate a file umd/rhyme-lang.min.js that you can include in your HTML file.

Code Structure

Currently the code is structured into four main javascript files:

  • src/rhyme.js: Contains the main APIs that are exposed to the user.
  • src/ir.js: Contains the logic for creating the Rhyme intermediate representation (IR) from input query ASTs.
  • src/codegen.js: Contains the logic for generating optimized javascript code from the Rhyme IR.
  • src/parser.js: Contains the logic for a preliminary parser that provides a simple textual interface for writing certain Rhyme expressions.

Running tests

npm test will run all the tests that are in the test directory.

If you're using VSCode, you can install Jest Runner extension and run/debug individual tests.

Useful Links