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

@runbook/bindings

v0.3.15

Published

* Condition: this is something that we are looking for in the * Situation: this is the 'json object' that we are looking for the condition in * Mereology: This is a little knowledge about 'what is a part of what'. For example a wheel is part of a car, but

Downloads

20

Readme

This is a project that supports the matching of conditions in json objects. It is used in the runbook project to match conditions in the runbook.json file.

Terminology

  • Condition: this is something that we are looking for in the
  • Situation: this is the 'json object' that we are looking for the condition in
  • Mereology: This is a little knowledge about 'what is a part of what'. For example a wheel is part of a car, but isn't a car (so not inheritance)
  • Inheritance: This is the 'isa' relation. For example 'leo' is a 'service' and 'prod' is as 'environment'
  • ReferenceData: We know a lot about the world that we don't put in the situation. For example we know the domain and port of a service in the production environment. This information lives in referenceData
  • Binding: This is a 'place that the condition is true in the situation'. Often there will be multiple bindings for a condition

How it works

We do a depth first search in the situation. However to avoid creating a huge number of unnecessary objects we use ' continuation passing style' and at the bottom of the tree we carry on with the next branch without returning from the call.

This has the potential to blow the stack if the condition was horribly complicated, but the vast majority of conditions are simple and this goes very fast.

We also separate 'compilation time' from the 'run time' although this is mostly invisible to the caller. All the data about the condition is resolved 'up front'. So for example if the condition is '{service: service}' then we do the detection +and parsing of this only once (before the first run). This is a big performance win.

Optimisations

When we have a condition that is an object we:

  • We do as much processing in 'compilation time' (aka before the first run) as possible
  • preferentially match the things that aren't variables... because if they succeed they don't create a binding, and if they fail they prevent further processing
  • Prefer branches with a small number of variables over a large number of variables

Examples

See the tests