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

@heiwa4126/worktime-html-csv

v0.1.2

Published

Parse worktime HTML tables and convert them to pivot-style CSV. Dual ESM/CJS output, TypeScript types, and CLI tool. Supports Node.js (linkedom) and browser (native DOM).

Readme

worktime-html-csv (@heiwa4126/worktime-html-csv)

npm version License: MIT TypeScript Node.js

ある特定のウェブページの HTML の特定テーブルを処理して、CSV として出力する npm パッケージです。きわめて特定の目的にだけ使われるので、汎用性は低いです。

テンプレートとして流用できるかもしれません。

仕様

Node とブラウザの両方で動作するように、CSV ライブラリは papaparse を使用

  • Node.js バージョン: DOM アクセスはlinkedom を使って高速処理
  • DOM バージョン: ネイティブ DOM API を使用
  • IIFE バンドル: ブラウザ上では ESM スクリプトだけでなく、クラシックスクリプト版のビルドも添付(バンドル済み)
  • CLI ツール: HTML ファイルから CSV に変換するコマンドラインツール付き
  • デュアルフォーマット: ライブラリとして使う場合は ESM, TS(.d.ts), CommonJS をサポート

インストール

pnpm add @heiwa4126/worktime-html-csv
# または
npm install @heiwa4126/worktime-html-csv

使い方

ライブラリとして利用 (Node.js)

ES Modules (MJS)

examples/ex1.mjs

import { parseWorktimeHtmlToData, toWideArray, toCSVString } from "@heiwa4126/worktime-html-csv";
import { readFileSync } from "fs";

const html = readFileSync("test_data/test1.html", "utf8");
const rows = parseWorktimeHtmlToData(html);
const wideArray = toWideArray(rows);
console.log(toCSVString(wideArray));

CommonJS (CJS)

examples/ex1.cjs

const { parseWorktimeHtmlToData, toWideArray, toCSVString } = require("@heiwa4126/worktime-html-csv");
const { readFileSync } = require("fs");

const html = readFileSync("worktime.html", "utf8");
const rows = parseWorktimeHtmlToData(html);
const wideArray = toWideArray(rows);
console.log(toCSVString(wideArray));

ブラウザ版をライブラリとして使用

ウェブアプリケーションや Chrome 拡張ではブラウザ版を利用してください

import { parseWorktimeHtmlToData, toWideArray } from "@heiwa4126/worktime-html-csv/browser";
// 以下同様

ブラウザ版には DOM を直接参照する parseWorktimeDomToData(document) があります。

HTML 上で利用

クラッシックスクリプト版:

<script src="path/to/parse.browser.global.js"></script>
<script>
  const html = document.documentElement.outerHTML;
  const rows = WorktimeHtmlCsv.parseWorktimeHtmlToData(html);
  const wideArray = WorktimeHtmlCsv.toWideArray(rows);
  console.log(wideArray);
</script>

ESM スクリプト版:

<script type="importmap">
  {
    "imports": {
      "papaparse": "https://esm.sh/papaparse@5"
    }
  }
</script>
<script type="module">
  import { parseWorktimeHtmlToData, toWideArray } from "path/to/parse.browser.js";
  const rows = parseWorktimeHtmlToData(testHtml);
  const wideArray = toWideArray(rows);
</script>

詳しくは examples/local_http/*.html を参照。

CDN に展開されていたら CDN も使えます。 examples/cdn/*.html を参照。

CLI ツールとして利用

インストール後、CLI コマンドが利用できます。

$ worktime-html-csv -h

Usage: worktime-html-csv [-h|--help] [-v|--version] [--bom] <input.html> [<output.csv>]

Options:
	-h, --help     Show this help message
	-v, --version  Show version
	--bom          Add UTF-8 BOM for Excel compatibility

If <output.csv> is omitted, output will be written to stdout.

開発

# 依存パッケージのインストール
pnpm install

# ビルド
pnpm run build

# テスト(Node.js版+ブラウザ版をnodeで)
pnpm test

# Lint
pnpm run lint

# フォーマット
pnpm run format

# 公開前チェック(lint, 両バージョンのテスト, clean, build, smoke test)
pnpm run prepublishOnly

ブラウザ版のテスト

  1. ビルド: pnpm run build

  2. Hono で書いたテスト用 HTTP サーバーを起動: pnpm start

  3. ブラウザでテストページを開く:

    http://localhost:3000/ をブラウザで開くと、以下が表示されます

    • classic.html - 見た目がつまらない.ブラウザのコンソール(F12)で結果を確認
    • classic2.html - ボタンを押すと画面更新&クリップボードにコピーされる
    • esm.html - 見た目がつまらない.ブラウザのコンソール(F12)で結果を確認
    • esm2.html - ボタンを押すと画面更新&クリップボードにコピーされる

CDN 版のテスト

npmjs 経由で各 CDN に出まわったら

でテストできます。サーバ不要。HTML をそのままブラウザで開けば OK

ライセンス

MIT