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

domsubi

v0.2.1

Published

A Virtual-DOM Library for JavaScript

Downloads

12

Readme

npm version Downloads

domsubi

ブラウザ側のDOM更新をFRPで処理するためのライブラリ。前提としてsodium-typescriptを利用する。

ヴァーチャルDOM実装でもあるが、facebook-reactのJSXとは異なるjavascriptのオブジェクトリテラルを活かした記法(jshtml記法)を採用。

名称はdomsubi = DOM-MUSUBI、DOMのおむすび。sodium(塩)を核にしてDOMを管理するところから。

インストール

umd(依存ライブラリを含めたバンドル版)

domsubiがグローバル変数になる。

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/domsubi/dist/domsubi.umd.js"></script>

esm(依存ライブラリを含めたバンドル版)

<script type="module" src="https://cdn.jsdelivr.net/npm/domsubi/dist/domsubi.min.js"></script>

esm(別途sodiumjsのモジュール版のインポートが必要)

<script type="module" src="https://cdn.jsdelivr.net/npm/domsubi/dist/domsubi.esm.js"></script>

npm

$> npm install domsubi
$> npm install -g domsubi

使用例

domsubi example pageにて紹介。

jshtml記法について

jshtml記法ではJavaScriptオブジェクトリテラルでDOMを記述する。入れ子構造をシンプルに扱えるので、FRP値をDOMに手軽に埋め込むことができる。原案となった制作者のページは既にないが、取り扱いの容易さから採用している。

要素の表現

要素は{ タグ: 内容 }とすることで記述できる。属性を含む場合は、$をキーとして記述する。

{ p: 'Hello World', $: { title: 'Goodbye World' } }
// => <p title="Goodbye World">Hello World</p>

イベントハンドラの表現

属性値としてイベントハンドラが想定される個所では、Function,EventListenerObjectを指定できる。

{ p: 'Hello World',
  $: {
    title: 'Goodbye World',
    onclick: (e) => console.log(e), // OK
    ondblclick: { handleEvent(e) { console.log(e) } } // OK
  }
}

インラインスタイルの表現

style属性はCSSStyleDeclarationにならい、名前付きプロパティをObjectで表現することができる。

{ p: 'Hello World',
  $: {
    style: {
      backgroundColor: 'white',
      // "background-color": 'white' でも可
    }
  }
}
// => <p style="background-color: white;">Hello World</p>

カスタムデータ属性の表現

data-*属性については、datasetプロパティのObjectで表現できる。

{ p: 'Hello World',
  $: {
    dataset: {
      exampleMessage: 'Goodbye World' // data-example-message属性になる
    }
  }
}
// => <p data-example-message="Goodbye World">Hello World</p>

複数ノードの表現

複数のノードを持つ場合はArrayを使えばよい。

{ p: [{ em:'H' },'ello World'] }
// <p><em>H</em>ello World</p>

FRP値からノードを生成する

jshtml記法の中で、DOMにFRPを取り込む時はsodium/Cellを用いればよい。

const message = new CellSink('Hello');
const paragraph = new jshtml({ p: [message,' World'] })
paragraph.mountAsContents(document.body);

message.send('Goodbye'); // <p>Hello World</p> => <p>Goodbye World</p>

ノードの他、属性リスト、属性値にもFRP値を指定できる。

const attr_title_value = new CellSink('Hello');
const attr_values = new Cell({ title: attr_title_value  });
const paragraph = new jshtml({ p: 'World', $: attr_values })
paragraph.mountAsContents(document.body);

attr_title_value.send('Goodbye'); // <p title="Hello">World</p> => <p title="Goodbye">World</p>

イベントはsodium/StreamSinkによってStreamとして取得できる。

const sMouseout = new StreamSink();
const paragraph = new jshtml({ p: 'Hello World', $: { onmouseout: sMouseout } })
paragraph.mountAsContents(document.body);
sMouseout.listen((e) => console.log('mouseout from paragraph'));

ノードからFRP値を生成する

ヘルパー関数群を用いて生成済みのノードからFRP値を取得できる。

events - DOMイベントをStream化する

const sKeydown = events(document).keydown; // Stream<KeyboardEvent>
sKeydown.listen((e) => console.log(e)); // KeyboardEvent

mutations - DOMの変異をStream化する

const sMutateChild = mutations(document.body, { childList: true }); // Stream<MutationRecord>
sMutateChild.listen((r) => console.log(r)); // MutationRecord

attributes - 属性値のCellを取得する

const attrCell = attributes(document.body).id; // Cell<string>
document.body.setAttribute('id', 'sample-doc');
attrCell.sample(); // "sample-doc"