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

@chartguard/runtime-chartjs

v0.1.1

Published

Optional opt-in runtime validation wrapper for chartjs

Readme

@chartguard/runtime-chartjs

Checks a Chart.js config when the chart is created and every time it is updated, through Chart.js's own plugin hooks. Opt-in per chart: nothing is registered globally and Chart.js is not patched.

Status: pre-release (0.x). Coverage is partial, and the API and settings may still change between minor versions.

npm install @chartguard/runtime-chartjs
import { Chart } from "chart.js";
import { guard } from "@chartguard/runtime-chartjs";

const chart = new Chart(canvas, guard(config));
chart.data.datasets[0].borderWidth = settings.width; // "wide", read from a settings file
chart.update(); // warns: $.data.datasets[0].borderWidth (Expected number, got string.)
  • Creation: the config is checked as it was passed to guard (Chart.js writes default scales into it afterwards), against the running Chart.version unless you name one.
  • Updates: the chart's own type, data and options are checked before each update(), except options.scales, which Chart.js merges with its defaults: while they are still the scales the chart was first drawn with, what creation found on them stands; once they change, the result notes that they are not checked (CFG_UNCHECKED) and is partial. One guarded config may build several charts; each is tracked on its own.
  • What is registered: each check reads what Chart.registry holds at that moment, plus the inline plugins of the config (plugins: [Legend]). On a tree-shaken Chart.js (Chart.register(...) instead of chart.js/auto), a controller or scale that is not registered is a confirmed CFG_UNREGISTERED error (Chart.js would throw), and an option of a plugin that is neither registered nor inline is CFG_INEFFECTIVE. registriesOf(Chart, config.plugins) gives the same context for your own validation.
  • Reporting: onResult(result, { phase, mode }) receives every result. Without it, a result with confirmed errors is written with console.warn; nothing else is logged, except a config that turns the guard off (Known limits).
  • Blocking: guard(config, { block: true }) does not draw an invalid config: an invalid creation is not drawn at any render, the first one included, and an invalid update is cancelled; Chart.js keeps what it drew before. Nothing is thrown inside Chart.js.
  • validator replaces the shipped schema (for example withExtensions([...]) from @chartguard/config-chartjs), options passes registries or libraryVersion, updates: false checks creation only.

guard never changes the config you pass and never runs its getters. To validate before construction and throw instead, use validateBeforeCreate(config, (checked) => new Chart(canvas, checked)).

Known limits

  • Turning the guard off: with options.plugins: false (or options.plugins.chartguard: false) Chart.js calls none of the guard's hooks, so the chart is neither checked nor blocked. guard warns about it with console.warn, and with block: true refuses the config with a TypeError. When options or options.plugins is behind a getter, the guard does not run it and cannot tell.
  • Inline plugins: guard adds its plugin to config.plugins. When config.plugins is an accessor or not an array, it refuses the config with a TypeError instead of running the getter or dropping your plugins. An inline plugin behind a getter is kept and not read, so the plugin registry is incomplete: options of unregistered plugins are then not claimed ineffective.
  • Reporter errors: an onResult that throws never throws inside Chart.js (the chart is created and drawn as without it); its error is rethrown in a microtask, where the host reports it as uncaught.
  • Version: the running version is version of the chart's class, or of the class it extends (class MyChart extends Chart), read as a data property; when there is none, the config is checked as the schema's version.