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

be-it

v0.0.23

Published

*be-it* is a vaguely named custom enhancement for DOM elements, whose mission is rather obscure but quite important. It allows deriving and forwarding [microdata](https://developer.mozilla.org/en-US/docs/Web/HTML/Microdata) values from meta and link tags

Downloads

11

Readme

be-it

be-it is a vaguely named custom enhancement for DOM elements, whose mission is rather obscure but quite important. It allows deriving and forwarding microdata values from meta and link tags to and from properties of other DOM (custom) elements. "it" stands for "itemized and transformed", if that helps remember the name.

Basically be-it attempts to fill in some gaps in the microdata specification, as far as specifying a full binding framework.

This allows applications to hydrate without having to pass and parse data separately, and provide search engines with accurate information.

Playwright Tests NPM version How big is this package in your project?

It works well with other custom enhancements, including be-sharing and be-linked:

<div itemscope 
    be-scoped='{
        "count": 30,
        "description": "Mr. Banks flying a kite with his kids.",
        "isHappy": true
    }'
    be-sharing='
        Share * from scope.
    '
>
    <link itemprop=isHappy be-it=disabled>
    <meta itemprop=count be-it=maxLength>
    <input>
    <meta itemprop=description be-it=alt>
    <img>
</div>

be-it also supports hydrating the value in the opposite direction from server rendered HTML:

<link itemprop=isWaiting be-it=disabled🌩️>
<meta itemprop=someNumber itemtype="https://schema.org/Number" be-it=maxLength🌩️>
<input disabled maxlength=37>

...updates the microdata so it matches the initial values of the input element.

Auto-forwarding property to next element sibling:

<link itemprop=isWaiting be-it=disabled>
<meta itemtype="https://schema.org/Number" be-it=maxLength>
<input>

be-it skips over other link/meta tags when searching for the target element to apply the property to.

To specify, instead, to pass the property to the previous element sibling, or the parent, you will need to switch to JSON mode:

<input>
<link be-it='{
    "prop": "disabled",
    "targetRel": "previousElementSibling"
}'disabled>
<meta itemtype="https://schema.org/Number" be-it=maxLength>

Auto-forwarding property to other peer elements

be-it also supports passing the value to multiple elements within the parent element scope, based on markers:

<meta itemprop=path be-it=-name;-id;-html-for;value>
<button class="expander" part=expander be-linked='
    Elevate value property to toggled-node-path marker.
'></button>
<label -html-for part=key class=key itemprop=name></label>

<meta itemprop=type>
<meta itemprop=value be-it=value>
<input -name -id class=value part=value be-linked='
    Elevate $0 property to edited-node marker.
'>

These marker-based bindings are given lower priority compared to the primary binding (subject to change).

Editing JSON-in-html can be rather error prone. A VS Code extension is available to help with that, and is compatible with web versions of VSCode.

Deriving initial value from SSR

As mentioned above, to support hydrating from server rendered HTML, add the "cloud with lightning" emoji (on windows, flying window + "." and search for cloud with lightning).

<link itemprop=isHappy be-it=checked🌩️>

Two-way binding

be-it supports a two way binding option if the name of the property to share ends with a 🔃 character. (On windows, type flying window + ".", and search for clockwise vertical arrow.)

<link itemprop=isHappy be-it=checked🔃>
<input type=checkbox>

This will cause the checkbox to notify the source's isHappy property of the change.

Conditionally displaying a template element

<link itemprop=isHappy be-it=content-display>
<template>
    <my-content></my-content>
</template>

Transforming peer elements [TODO]

be-it can also disseminate its value to other peer elements within the Shadow DOM realm, using DTR syntax:

<span><span>
<link itemprop=isHappy be-it='{
    "prop": "checked",
    "twoWay": true,
    "transform": {
        "span": "."
    }
}'>
<input type=checkbox>

If different values should be passed based on whether the value of itemprop is truthy or falsy, use the transformIfTruthy, transformIfFalsy properties.

Viewing Your Element Locally

  1. Install git.
  2. Fork/clone this repo.
  3. Install node.h
  4. Open command window to folder where you cloned this repo.
  5. npm install

  6. npm run serve

  7. Open http://localhost:3030/demo/ in a modern browser.

Running Tests

> npm run test