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

@suzukihayate/wareki

v0.1.0

Published

西暦と和暦(令和・平成・昭和・大正・明治)を相互変換する依存ゼロのライブラリ。改元日は ICU/Intl 準拠。

Readme

wareki

西暦と和暦(令和・平成・昭和・大正・明治)を相互変換する、依存ゼロの小さなライブラリです。 改元日は ICU/Intl(ja-JP-u-ca-japanese)と同じ境界を採用しているため、改元の前後でも正確に変換できます。

  • 依存ゼロ・型定義つき(TypeScript)・ビルド不要(ESM をそのまま import)
  • Node / Deno / Bun / ブラウザで動作

インストール

npm install @suzukihayate/wareki

使い方

import { toWareki, format, parse, toGregorianYear } from '@suzukihayate/wareki';

format(new Date(2024, 5, 2));          // "令和6年6月2日"
format('2019-05-01');                  // "令和元年5月1日"
format('2024-06-02', { initial: true }); // "R6.6.2"

toWareki('1989-01-07'); // { eraName: '昭和', year: 64, ... }
toWareki('1989-01-08'); // { eraName: '平成', year: 1,  ... }

parse('令和6年6月2日'); // → Date(2024-06-02)
parse('H31.4.30');      // → Date(2019-04-30)

toGregorianYear('令和', 6); // 2024

API

  • toWareki(input)Date / "YYYY-MM-DD" / {year,month,day} を和暦オブジェクトに変換
  • format(input, { gannen?, initial? }) — 和暦文字列に整形(gannen は1年目を「元年」表記、既定 true)
  • parse(str)"令和6年6月2日" / "R6.6.2" などを Date に変換
  • toGregorianYear(eraName, warekiYear) — 和暦年 → 西暦年
  • eras — 対応元号の一覧(改元日つき)

なぜ作ったか

和暦変換は日本の業務アプリで頻出ですが、改元日(特に昭和→平成、平成→令和の“同じ年内での切り替わり”)を正しく扱う軽量ライブラリは意外と少なめです。本ライブラリは改元境界を ICU と揃え、依存ゼロ・型つきで“そのまま import するだけ”を目指しました。

テスト

node --test

License

MIT © 2026 Hayate Suzuki