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

rogain-component-if

v1.1.0

Published

Rogain <If /> helper component

Downloads

13

Readme

rogain-component-if

<If data={variable} or and not equal defined empty gt gte lt lte />

Passes its children through if data passes defined attribute tests. Any trees defined after the <Else /> will be passed through if data doesn't pass attributes tests.

The attributes and, or, and not can be used to define how all tests should logically be grouped. The attribute predicates equal, defined, empty, gt, gte, lt, lte can be used to test against the data attribute value.

Attributes

Attribute | Description --- | --- data | Variable or Expression. and | Runs all tests with AND logic, short circuits when any predicate fails. The default is and if or is not defined. or | Runs all predicates with OR logic, short cicuits when any predicate passes. not | Negates the end result of all tests.

Attribute Predicates

Attribute | Description --- | --- equal | Variable or Expression. returns true if it's value is equal to data defined | if defined, returns true if data is defined empty | if defined, returns true if data is an empty array or object gt | Variable or Expression. returns true if it's value is greater than data gte |Variable or Expression. returns true if it's value is greater than or equal to data lt | Variable or Expression. returns true if it's value is less than data lte | Variable or Expression. returns true if it's value is thess than or equal to data

Examples

Default Predicates / Else

If no tests are defined, the default predicates are <If data={var} and defined empty="false"></If>

<If data={loggedIn} equal="true">
    <Dashboard />
<Else />
    <Login />
</If>

Negated Predicates

<If data={error} defined="false">Way to go, no errors!</If>
<If data={error} not defined>Way to go, no errors!</If>

Complex Predicates

If and or or attributes aren't defined the predicates will be run using AND logic by default.

<If data={index} lt="100" gte="0">10 - 99</If>
<If data={index} lt="1000" gte="100">100 - 999</If>
<If data={index} gte="1000">1000+</If>

OR Logic

<If data={mythings} or empty defined="false">MY THINGS BE MISSING</If>

Install

With npm do:

npm install rogain-component-if

License

MIT