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

@actualwave/primitive-type-checker

v0.2.3

Published

Runtime type check for primitive value types (uses typeof and identifies arrays).

Readme

@actualwave/primitive-type-checker

Coverage Status

Runtime type checker for primitive value types. Uses typeof to identify types and detects arrays specifically (since typeof [] === 'object'). Designed as a plugin for the @actualwave/type-checkers framework.

Installation

npm install @actualwave/primitive-type-checker

Usage

With the type-checkers framework

import { wrap, setDefaultTypeChecker } from '@actualwave/type-checkers';
import { createPrimitiveTypeChecker } from '@actualwave/primitive-type-checker';

setDefaultTypeChecker(createPrimitiveTypeChecker());

const obj = wrap({ count: 0, label: 'hello', items: [] });

obj.count = 1;        // OK
obj.count = 'one';   // TypeError reported: expected number, received string
obj.items = {};      // TypeError reported: expected array, received object

Custom error reporter

import { setErrorReporter } from '@actualwave/primitive-type-checker';

setErrorReporter((action, name, required, received) => {
  throw new TypeError(
    `${action} on "${name}": expected ${required}, got ${received}`
  );
});

Reporting levels

Control how strictly types are tracked per object or property:

import {
  REPORT_FIRST_TYPE_ONLY,
  REPORT_ALL_ASSIGNED_TYPES,
  REPORT_NEVER,
  setReportingLevel,
} from '@actualwave/primitive-type-checker';

// Track only the first observed type (default)
setReportingLevel(obj, REPORT_FIRST_TYPE_ONLY);

// Accept any type ever assigned without reporting errors
setReportingLevel(obj, REPORT_NEVER);

API

createPrimitiveTypeChecker(collectTypesOnInit?, enableGetChecker?)

Factory function — returns a PrimitiveTypeChecker instance.

| Parameter | Type | Default | Description | |---|---|---|---| | collectTypesOnInit | boolean | true | Scan wrapped object properties on init to record initial types | | enableGetChecker | boolean | true | Also check types on property reads, not just writes |

setErrorReporter(reporter) / getErrorReporter()

Replace or retrieve the active error reporter.

type Reporter = (action: string, name: string, required: string, received: string) => void;

Reporting level constants

| Constant | Meaning | |---|---| | REPORT_FIRST_TYPE_ONLY | Only the first observed type is enforced (default) | | REPORT_ALL_ASSIGNED_TYPES | Every distinct type ever assigned is recorded | | REPORT_NEVER | Type tracking disabled for the target |

Action constants

Passed as the action argument to the error reporter:

| Constant | Value | |---|---| | GET_PROPERTY | '(GetProperty)' | | SET_PROPERTY | '(SetProperty)' | | ARGUMENTS | '(Arguments)' | | RETURN_VALUE | '(ReturnValue)' | | MERGE | '(Merge)' |

getTypeValue(value)

Returns the type string for any value — same as typeof but returns 'array' for arrays and '' for undefined.

Type detection

| Value | Returned type | |---|---| | undefined | '' (empty string) | | [], new Array() | 'array' | | {}, null | 'object' | | 42, NaN | 'number' | | 'text' | 'string' | | true / false | 'boolean' | | () => {} | 'function' | | Symbol() | 'symbol' | | 1n | 'bigint' |

License

MIT