native ESM · zero runtime dependencies · no build

Know what a value is.
Enforce what it should be.

strong-type gives JavaScript one clear type-checking surface across browsers and Node. Strict checks throw. Non-strict checks return booleans. The source you read is the source the runtime executes.

  • isomorphic core
  • 201 documented validators
  • 90.42% native executable-line coverage
type-gate.js
import Is from 'strong-type';

const is=new Is;
const value=new Map;

is.map(value);       // true
is.string(value);    // TypeError

Native by design

Nothing between your code and JavaScript.

There is no production dependency tree, CommonJS copy, transpiler, framework, or bundle. The optional Node adapter imports only built-in Node modules and never enters the default import graph.

Project guarantees
PropertyGuaranteeWhat it means
Module formatNative ESMRun the checked-in JavaScript directly.
Runtime dependenciesNoneNo third-party production packages.
Build stepNoneNo bundler or transpiler is required.
Default entrystrong-typeBrowser-safe and Node-safe.
Node entrystrong-type/nodeExplicit Node built-ins and exact util checks.
Testsvanilla-test 2.1.01,178 focused tests across four exclusive suites, plus guarded capability skips.

Install

One package. Two explicit entry points.

npm
npm install strong-type
Import options
ImportRuntimeContentsBuild required
strong-typeBrowser + Node183 isomorphic validatorsNo
strong-type/index.jsBrowser + NodeCompatibility path to the same coreNo
strong-type/nodeNode onlyCore plus 18 Node validatorsNo
strong-type/node.jsNode onlyCompatibility path to the Node adapterNo

Quick start

Strict when enforcing. Boolean when inspecting.

JavaScript
import Is from 'strong-type';

const is=new Is;
const weakIs=new Is(false);

is.string('strong-type');        // true
weakIs.number('42');             // false
is.union(new Map,'map|set');     // true

is.number('42');                 // throws TypeError
Strict and non-strict behavior
ModeCreatePassing checkFailing check
Strictnew IstrueThrows TypeError
Non-strictnew Is(false)truefalse

Direct browser import

Use a module script. Still no bundle.

Load the checked-in module directly from this project’s own Pages URL, or self-host the same file. The browser executes it as native ESM.

HTML · direct URL
<script type="module">
    import Is from 'https://riaevangelist.github.io/strong-type/index.js';

    const is=new Is;
    console.log(is.url(new URL('https://example.com')));
</script>

For a bare package name, point a native import map at your self-hosted package file:

HTML · import map
<script type="importmap">
{
    "imports": {
        "strong-type": "./node_modules/strong-type/index.js"
    }
}
</script>

<script type="module">
    import Is from 'strong-type';
    console.log(new Is(false).string('native ESM'));
</script>
Serve modules over HTTP. No bundle, transform, runtime shim, or host switch is involved.

Runtime boundary

The default graph stays isomorphic.

Browserimport Is from 'strong-type'
index.jszero host imports
Nodeimport Is from 'strong-type'
Node precisionimport Is from 'strong-type/node'node:* built-ins only

Tested in public

Web-standard tests. Native coverage.

The four-suite registry runs through vanilla-test 2.1.0. Its native Node V8 collector measures only the shipped runtime sources and enforces per-file release floors in CI.

1,178passing tests
90.42%executable lines
69.42%V8 block ranges
98.80%function ranges
See suites, coverage, and CI matrix

Focused documentation

Choose the page for the job.