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.96% 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,268 focused tests across five exclusive suites, plus seven shared behaviors in Node and real Chrome. |
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.
strong-type works with bundlers and without a bundler. Bundlers resolve the bare package import normally. Native browser ESM uses an import map and executes the same checked-in module with no build or transpilation step.
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>node_modules file; file:// is not supported. There are no runtime dependencies, so no dependency entries or nested-version scopes are needed.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 five-suite registry runs through vanilla-test 2.1.0. A shared bare-import behavioral inventory also runs unchanged in Node and real Chrome through the explicit browser import map. The native Node V8 collector measures only the shipped runtime sources and enforces per-file release floors in CI.
Focused documentation