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

@t15i/webidl-types

v3.0.0

Published

TypeScript implementations of WebIDL types

Readme

webidl-types - TypeScript implementations of WebIDL types

Callable, interned type objects for the WebIDL type system. Each type is a function you call with a JavaScript value to get back the value converted according to its WebIDL rules. The conversion algorithms themselves — long wrapping, unsigned long clamping, DOMString stringification, and so on — are provided by @t15i/webspecs; this package wraps them into composable, introspectable Type objects.

Coverage is intentionally narrow — this is a knowledge base, not a polyfill. Only the types that have been ported so far are listed below; everything else is marked with ....

Install

npm install @t15i/webidl-types

@t15i/webspecs is a peer dependency and must be installed alongside it:

npm install @t15i/webspecs

Usage

Every type is exposed from a single entry point:

import {
  Long,
  DOMString,
  Nullable,
  Sequence,
  Union,
  Annotated,
  EnforceRange,
  // ...
} from "@t15i/webidl-types";

Types are converters

Call a type with a value to convert it per its WebIDL rules:

Long(42); // 42
Long("42"); // 42        (ToNumber, then integer conversion)
Long(4294967297); // 1   (wraps modulo 2^32)
Long(3.9); // 3          (truncates toward zero)

UnsignedLong(-1); // 4294967295
DOMString(123); // "123"
Boolean(0); // false

Types compose

The generic factories build compound types from other types. The result is itself a callable type:

const Ids = Sequence(Long);
Ids([1, 2, 3]); // [1, 2, 3]

const Name = Nullable(DOMString);
Name(null); // null

const Tags = FrozenArray(DOMString);
Object.isFrozen(Tags(["a", "b"])); // true

const Headers = Record(DOMString, DOMString);
const Id = Union(Long, DOMString);

Annotated types carry extended attributes

Wrap a type with WebIDL extended attributes to change how it converts. The attribute markers are re-exported from @t15i/webspecs:

import { Annotated, Long, Clamp, EnforceRange } from "@t15i/webidl-types";

Annotated({ [Clamp]: null }, Long)(4294967297); // 2147483647 (clamped)
Annotated({ [EnforceRange]: null }, Long)(4294967297); // throws TypeError

Types are interned

Structurally equal types are the same object, so you can compare them by identity. Building a type is memoized through the shared typeRegistry:

Nullable(Long) === Nullable(Long); // true
Union(Long, DOMString) === Union(Long, DOMString); // true

Each type also exposes its structural metadata — for example innerType on a Nullable, memberTypes on a Union, and K / V on a Record — which the registry uses to derive a stable id for interning.

What's implemented

A checklist of every WebIDL type. Checked items are implemented and exported by this package.

  • [ ] any
  • [x] undefinedUndefined
  • [x] booleanBoolean
  • [ ] byte
  • [ ] octet
  • [ ] short
  • [ ] unsigned short
  • [x] longLong
  • [x] unsigned longUnsignedLong
  • [ ] long long
  • [ ] unsigned long long
  • [ ] float
  • [ ] unrestricted float
  • [x] doubleDouble
  • [ ] unrestricted double
  • [x] bigintBigInt
  • [x] DOMStringDOMString
  • [ ] ByteString
  • [x] USVStringUSVString
  • [ ] object
  • [ ] symbol
  • [x] interface types → InterfaceType
  • [ ] callback interface types
  • [ ] dictionary types
  • [ ] enumeration types
  • [ ] callback function types
  • [x] nullable types → Nullable
  • [x] sequence types → Sequence
  • [ ] async iterable types
  • [x] record types → Record
  • [ ] promise types
  • [x] union types → Union
  • [x] annotated types → Annotated
  • [ ] buffer source types
  • [x] frozen array types → FrozenArray
  • [ ] observable array types

License

MIT