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

@pawn002/okca

v1.0.1

Published

OK Contrast Algorithm — OKLCH-native, WCAG-compatible contrast ratio with zero false passes

Readme

okca — OK Contrast Algorithm

OKCA is a color contrast algorithm that improves on WCAG 2.x while staying fully compatible with it: same 1–21 scale, same AA (4.5) and AAA (7.0) thresholds, and a mathematical guarantee of zero false passes — OKCA never approves a pair that WCAG rejects.

WCAG 2.x has two well-documented failure modes that OKCA closes:

  1. Saturated chromatic false passes. WCAG passes hot pink on near-black at 6.6:1 — a comfortable AA score. Practitioners flag it as inadequate; OKCA scores it 3.7. The difference is that WCAG's luminance formula cannot distinguish saturated colour from grey at the same luminance, while OKCA can.

  2. Polarity blindness. WCAG treats contrast(A on B) and contrast(B on A) as identical. Design systems and practitioners do not — dark mode and light mode are different decisions. OKCA scores them differently.

Install

npm install @pawn002/okca

Usage

contrast(foreground, background) — first argument is the element being evaluated (text, icon, or other visual element), second is the surface it sits on. Argument order matters: okca(A, B) ≠ okca(B, A).

import { contrast } from '@pawn002/okca';

contrast('#ffffff', '#000000');  // 21.0 — white on black
contrast('#000000', '#ffffff');  // 20.0 — black on white

// WCAG AA boundary grey — fails in both directions
contrast('#ffffff', '#767676');  // 3.5
contrast('#767676', '#ffffff');  // 3.3

// Chromatic false pass in WCAG — OKCA correctly fails
contrast('#ff69b4', '#1a1a1a'); // 3.7

Also accepts CSS oklab() and oklch() alongside hex:

contrast('oklab(1 0 0)', 'oklab(0 0 0)');           // 21.0
contrast('oklch(70% 37.5% 180deg)', '#ffffff');      // mixed formats ok

CommonJS:

const { contrast } = require('@pawn002/okca');

A class-based API is also available:

import { OkcaService } from '@pawn002/okca';
const okca = new OkcaService();
okca.contrast('#fff', '#000');  // 21.0

Properties

  • Polarity-aware: okca(foreground, background) ≠ okca(background, foreground) — scores differ by direction
  • Conservative: all scores at or below WCAG equivalent; AA/AAA thresholds unchanged
  • Zero dependencies: pure TypeScript, no runtime deps
  • Clean-room implementation: no third-party contrast algorithm source code

Validation

Tested against 1,249 color pairs across three batteries (light-on-dark, dark-on-light, design systems from Tailwind/GOV.UK/USWDS):

| Battery | Pairs | False Passes | WCAG Disagreements | |---------|------:|:------------:|:-----------------:| | Light-on-dark | 53 | 0 | — | | Dark-on-light | 54 | 0 | — | | Design systems | 1,142 | 0 | 111 | | Total | 1,249 | 0 | 111 |

False passes: zero. OKCA never approves a pair that WCAG rejects.

WCAG disagreements are pairs where OKCA scores below 4.5 but WCAG scores ≥ 4.5. These are intentional. WCAG's 4.5:1 AA threshold is widely considered too permissive — white on #767676 (WCAG's own AA boundary anchor) is not production-ready in most real-world designs. All 111 disagreements involve colors in that marginal zone.

Further reading

Algorithm design, calibration rationale, FP = 0 proof, and extension guidelines: docs/OKCA_DESIGN.md.

License

MIT