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
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.
| Property | Guarantee | What it means |
|---|---|---|
| Module format | Native ESM | Run the checked-in JavaScript directly. |
| Runtime dependencies | None | No third-party production packages. |
| Build step | None | No bundler or transpiler is required. |
| Default entry | strong-type | Browser-safe and Node-safe. |
| Node entry | strong-type/node | Explicit Node built-ins and exact util checks. |
| Tests | vanilla-test 2.1.0 | 1,178 focused tests across four exclusive suites, plus guarded capability skips. |
Install
One package. Two explicit entry points.
npm install strong-type| Import | Runtime | Contents | Build required |
|---|---|---|---|
strong-type | Browser + Node | 183 isomorphic validators | No |
strong-type/index.js | Browser + Node | Compatibility path to the same core | No |
strong-type/node | Node only | Core plus 18 Node validators | No |
strong-type/node.js | Node only | Compatibility path to the Node adapter | No |
Quick start
Strict when enforcing. Boolean when inspecting.
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| Mode | Create | Passing check | Failing check |
|---|---|---|---|
| Strict | new Is | true | Throws TypeError |
| Non-strict | new Is(false) | true | false |
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.
<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:
<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>Runtime boundary
The default graph stays isomorphic.
import Is from 'strong-type'import Is from 'strong-type'import Is from 'strong-type/node'→node:* built-ins onlyTested 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.
Focused documentation