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

r-ninja

v1.0.4

Published

r-ninja watches for changes in JSX expressions and updates UI with very less glue code.

Downloads

147

Readme

R-NINJA

Overview

From our experience with React, we observed that developers were writing a lot of code to handle state-to-ui and ui-to-state mediation. With watchers (as in Angular JS, Vue), lot of this glue code can be eliminated. Watchers are good when used in moderate. So, we believe that there are places (expecially higher order components like Pages, screens) where watchers can help React developers also with very less code.

R-NINJA is written based on watchers for React ecosystem. R-NINJA watches expressions in the JSX markup and triggers React Render when any one of the expressions value changes. Simple to use is the main goal behind R-NINJA. If R-NINJA is causing performance issues or doesn't satisfy a requirement, it can be easily removed completely or removed only for a certain page or component (check babel config below).

How to use

  • Install the package as dependency.
npm install r-ninja
  • Add the Ninja Context to the Root component.
import { NinjaContext, Watcher } from 'r-ninja';
import App from "./App.tsx";

export const Root = () => {
    return (
        <NinjaContext.Provider value={Watcher.ROOT}>
            <App />
        </NinjaContext.Provider>
    );
}
  • Change babel.config.json to add the Ninja plugin.
{
    "presets": [
        [
            "@babel/preset-react"
        ]
    ],
    "overrides": [{
        test: './src/pages/**/*.page.tsx',
        plugins: ['./node_modules/r-ninja/ninja.babel.plugin.js']
    }]
};

Note:In the above example, Ninja observes only files under src/pages folder and with names ending with page.tsx. Change the config based upon your project structure.

How it works

During babel transformations, Ninja wraps a Watcher around each JSX element that is present in the files that Ninja observes. During runtime, Ninja queries these watchers to check if there is a change in prop value of the React element. This process is called Check. If any property is changed, then React is asked to render only the component where change is observed.

During babel transformations, Ninja adds code to automatically trigger Check process when a event callback function is called. Code is added only in event callback that has prop name starts with 'on' (onChange, onSubmit). For the rest of the cases (setTimeout, setInterval and other async processes), developer has to explicitly start the Check process as follows.

import RNinja from 'r-ninja';
...
RNinja.check();
...

NOTE:

  • Watcher doesnot watch properties that have function or object literal attached.
  • For certain styles of JSX markup, we are not able to watch changes properly. Till we find a solution to those watch problems, use alternatives provided by r-ninja.
    • terinary operator: use When component
    • Map operator: use Repeat component

Contributers

License

MIT