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

iff-diff

v0.0.5

Published

<a href="https://nodei.co/npm/iff-diff/"><img src="https://nodei.co/npm/iff-diff.png"></a>

Readme

iff-diff

iff-diff is a simplified version of if-diff. iff-diff only affects its next sibling.

iff-diff supports setting (or removing) an attribute, a class, and/or a part from that next sibling, depending on the specified condition.

That is all.

iff-diff might be used in combination with a lazy loading component, like laissez-dom or lazy-mt.

Example Syntax

<!-- p-et-alia notation -->
<iff-diff iff -lhs equals -rhs set-attr="some-attribute" set-class="some-class" set-part="some-part"></iff-diff>
<div></div>

Other options to "equals" are "not-equals" and "includes".

lhs, rhs can be strings, numbers, or objects (in which case the two objects are compared recursively.)

Advantages

If this component is used inside a (code-centric) library capable of "declaratively" setting attributes on the "owned" elements, does this component make sense?

In that scenario, the "benefits vs cost" question probably only comes close if using the feature where the lhs and rhs can be objects, and the comparison can be made recursively.

By far, this component makes most sense to use in a HTML-first environment, where the goal is to avoid "context-switching" into JavaScript as much as possible. It benefits from the existence of other components capable of dynamically passing in the values of properties if, lhs, rhs, etc. declaratively. For example, with p-et-alia or the smaller on-to-me components:

<ways-of-science>
    <largest-scale>
        <woman-with-carrot-attached-to-nose></woman-with-carrot-attached-to-nose>
    </largest-scale>
    <p-d on=value-changed to=[-lhs] m=1 val=target.value></p-d>
    <largest-scale>
        <a-duck></a-duck>
    </largest-scale>
    <p-d on=value-changed to=[-rhs] m=1 val=target.value></p-d>
    <iff-diff iff -lhs not-equals -rhs set-attr=hidden></iff-diff>
    <div hidden>A witch!</div>
</ways-of-science>

Shared condition

Multiple iff-diffs can share the results of a single iff-diff instance:

<iff-diff id=source-of-truth -iff -lhs -equals -rhs set-attr="some-attribute" set-class="some-class" set-part="some-part"></iff-diff>
<div></div>
...
<iff-diff sync-with=source-of-truth set-class="some-other-class"></iff-diff>
<span></span>

To share the negation of another if-diff instance:

<iff-diff id=source-of-truth -iff -lhs -equals -rhs set-attr="some-attribute" set-class="some-class" set-part="some-part"></iff-diff>
<div></div>
...
<iff-diff anti-sync-with=source-of-truth set-class="some-other-class"></iff-diff>
<span></span>

Restrictions:

  1. This only works for instances within the same ShadowDOM realm.
  2. The source-of-truth instance is guaranteed to be found if the source-of-truth instance comes before the referencing instance(s) in the document order. This is most applicable when employing streaming.