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

rebylon

v1.0.10

Published

Reactive programming library designed to use with BabylonJS

Readme

Rebylon

Reactive programming library designed to use with BabylonJS

Effects

// Effect is just a function withouth arguments
const e1: Effect = () => console.log("test");
const e2: Effect = noop; // Do nothing

// Combine effects. In this case `composeEffects` will return e1, because e2 is noop
const e3: Effect = composeEffects(e1, e2);

Parameters

// Parameter declaration
const a: Param<number> = 5; // constant parameter
const b: Param<string> = () => Date.now().toFixed(); // variable parameter

// Parameters mapping
const c: Param<[number, string]> = map(a, b)((a: number, b: string) => {
    return [a * 5, b + "_mapped"];
});

// React on parameters change.
// Parameters modification will be checked on each `update` call
const update: Effect = changes(a, b)((a: number, b: string) => {
    console.log("Current parameters:", a, b);
});

// React on parameters change with some disposable state
const disposable: Component = stream(a, b)((a, b) => {
    if (a % 2) {
        const timeout = setTimeout(doSomething, 1000);
        return () => clearTimeout(timeout);
    }
});

// Write some parameters to object fields
const updateFields: Effect = write(myObject, {
    count: a,
    caption: b,
});

Components

Component is just an object with update and dispose effects. Minimal component is { update: noop, dispose: noop }.

// Some component pseudocode
function exampleComponent(scene, { color, position }: { position: Param<number>, color: Param<Color3> }): Component {
    const sphere = scene.createSphere(1);
    const update = write(sphere, { color, position });
    return {
        update: update,
        dispose: () => sphere.dispose(),
    };
}

// Optionaly append component to the scene
const visible: Param<boolean> = () => !(Date.now() % 2);
const optinalComponent: Component = optional(visible, () => {
    return exampleComponent(scene, { color: someColor, position: somePosition });
}); // component will be created/disposed depending on the `visible` flag

// Combine few components to one
const combined: Component = group(component1, component2, component3);

// Create a list of components
const someList: Param<number[]> = () => [1, 2, 3];
const many: Component = list(
    someList, // array parameter
    (value: number) => value, // key computation function (similar to React's key attribute)
    (value: Param<number>) => createMyComponent(scene, value) // function to create a component from the list item
);

// Cache havy calculations or parametrs that can change during updating
const time: Param<number> = () => Date.now();
const items: Param<number[]> = () => range(0, Date.now() % 100);
const cached: Component = cache(time, items)((time, items) => {
    return createMyComponent(
        scene, {
            // cached parameter time won't change during updating of my component and it's children
            time: time,
            // `items` parameter can be used multiple times without performance issues
            size: map(items)(items => items.length * 10),
            values: items
        },
    );
});

Component hooks

If you need to do something before/after update/dispose component, there are some hook functions. You can use beforeUpdate, afterUpdate, beforeDispose, and afterDispose functions.

const componentWithHook = beforeUpdate(createMyComponent(), () => {
    console.log("It runs before update");
})

Stateful components

const statefulComponent = state(0, (counter, setCounter) => {
    return // Return your component with state here
})

Animations

// Animated component example
interface AnimatedComponentProps {
    time: Param<number>;
    position: Param<"left" | "right">;
}

function animatedComponent(scene, { time, position }: AnimatedComponentProps): Component {
    const x: Param<number> = map(position)(p => p === "left" ? -1 : 1);
    const animatedX: Param<number> = numberTransition({
        time: time,
        value: x,
        duration: 300,
    });

    return createMyComponent(scene, {
        position: map(animatedX)(x => new Vector3(x, 0, 0)),
    });
}

// Create custom transition
export const vector3Transition = createTransition<Vector3>({
    equals: (a: Vector3, b: Vector3) => a.equals(b), // objects compare function
    mix: (a: Vector3, b: Vector3, t: number) => a.scale(1 - t).add(b.scale(t)), // objects mix function
});