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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@rkmodules/rules

v0.0.103

Published

`npm install @rkmodules/rules`

Readme

Usage

npm install @rkmodules/rules

Engine

An engine creates a namespace for functions, so create an engine to start with:

const engine = new Engine()

Specifying a function

A function definition is just a json object. It can be assembled together via code or just hardcoded. It is of type GraphedFunction and at least has to have a name and body field. The latter defines a graph with calls to primitives or other graphed functions:

const testFunction: GraphedFunction = {
    name: "test",
    body: {
        myVal: {
            name: "value",
            params: {
                type: "string",
            },
        },
        myLog: {
            name: "log",
            inputs: {
                data: "<myVal.value>",
            },
        },
    },
};

We get back to function definitions later

Running the function

  • build all the custom functions
  • run the one you need

use in react

useFunction

editor

  • Create an instance of the rules engine
  • create a function to work with
  • use the <Flow> component to create the editor
const engine = new Engine({
    // map of custom rules
});

const emptyFunction: GraphedFunction = {
    name: "test",
    body: {},
    outputs: {
        documents: "",
    },
};

export default function MyComponent() {
    const [fn, setFn] = React.useState(emptyFunction);
    return (
        <div>
            <Flow function={fn} engine={engine} onChange={setFn} />
        <div>
    );
}

TODO:

  • [ ] filtering of lists
    • document grasshopper nodes
    • build them
  • [ ] set value
  • [ ] inspection
    • run time
    • running flag
    • intermediate results

Components / functions

List

  • [x] listItem
  • [x] listLength
  • [x] graftTree
  • [x] trimTree

Math

  • [x] lessThan
  • [x] greaterThan

Text

  • formatting
  • text replacement

grasshopper investigation

value

using functions

in React context

  • use useFunction. This will build the function, mount it if needed and provides a run function.

in Vanilla context

  • use engine.build(fn) to build the function
  • use engine.mount(fn) to mount the function (if it has a mount function)
  • use engine.run(fn, inputs) to run the function

considerations

For Supa Lipu we have quite a lot of functions that need to be called on various events

  • when propobjects are updated / created / deleted.

    • currently, each propobject has its own engine and 1 single rule. This is fired when the object is mutated
    • all functions need to be propobjects as well, then referenced in various places
    • the engine needs to be global, so that functions can reference each other
      • for these references, we need propobject refs, to that dependency functions are loaded
    • in useObjectMutation, we fire an event such that mounted eventlisteners can react
  • we need deep references. On change, oldProps and changedProps are passed in as an object. So we need

    • primitives to getValue and setValue
    • [x] reference strings that can directly reference deeper objects to eliminate the need for getValue
  • [x] also need to think about data tree handling for outputs

Entries

  • in finance I had filterLine(on, match) function that filters return a boolean if any of the lines match. This is a hardcoded solition, which is ok for finance. But we might come up with something more generic