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

front-debugger

v0.0.4

Published

テスト環境だけでデバッグを表示するライブラリ。

Readme

FrontDebugger

npm npm npm

result

テスト用に入れた console.log をあとで全部消すのってめんどうですよね。
本番反映後も動きを確認したかったり何かあったときの調査のために console.log はそのままの方が何かと便利...という場面もあると思います。
このライブラリを使えば、テスト環境のときにだけ表示される console.log を簡単に用意することができます。

テスト環境の判定は自分で調整できるので、開発用のURLで判定したり、特定のパラメータがある時をテストモードと判定することができます。
また、スマホでのテストやエンジニア以外が見ることも考慮してフロント側にもログを表示する機能があります。

DEMO

デフォルトではURLに mode=test があるときだけコンソールと画面にデバッグ文言が表示されます。
テスト環境の判定は好きに変更ができます。

何も表示されない

https://yuki-sakaguchi.github.io/FrontDebugger/example/

デバッグが表示される

https://yuki-sakaguchi.github.io/FrontDebugger/example/?mode=test

導入

CDN

<script src="https://unpkg.com/front-debugger@latest/lib/front-debugger.min.js"></script>

npm install

npm install front-debugger

使い方

FrontDebugger というクラスが使えるようになるので、インスタンスを生成して console.log の代わりに log() メソッドを使うだけです。 使用感は console.log と全く変わりません。
このメソッドを使うと開発中判定の時だけコンソールと画面上にログが表示されます。

インスタンス生成時にオプションを設定できるので、画面上の表示はさせないようにしたり、開発中判定処理をカスタマイズすることができます。
デフォルトではURLに mode=test というパラメータがある時だけ開発中判定になります。

import FrontDebugger from 'front-debugger';

const fd = new FrontDebugger();
fd.log('テストモードの時にだけ表示されるログ');

オプション

const fd = new FrontDebugger({
  test: () => location.search.indexOf('mode=test') >= 0,
  isFront: true,
  isBackground: true,
  prefix: '[test log]',
  displayedTime: 2000,
  parent: 'body',
  className: 'front-debugger',
});

test: () => boolean

テストモードかどうかを判定する処理
デフォルトでは location.search.indexOf('mode=test') >= 0

isFront: boolean

フロント側にログを表示するかどうかのフラグ
デフォルトは true

isBackground: boolean

デベロッパーツールのコンソールにログを表示するかのフラグ
デフォルトは true

prefix: string

デベロッパーツールのコンソールにログを表示する際に付与される接頭語
デフォルトでは [test log]
空にすれば無視されます

displayedTime: number

フロント側にログを表示する場合のログの表示時間
単位は ms   デフォルトでは 2000

parent: string

フロント側にログを表示する場合、表示用に生成されるDOMを配置するセレクター
デフォルトでは body

className: string

フロント側にログを表示する場合に生成されるDOMに付与するクラス名
デフォルトでは front-debugger