Registry / testing / rtts_assert

rtts_assert

JSON →
library2.0.0-alpha.37jsnpmunverified

A run-time type assertion library for JavaScript, used internally by Angular for runtime type checks. Current stable version is 2.0.0-alpha.37 (pre-release, adapted from v0.1.0 originally designed for Traceur). No regular release cadence—packaged within Angular monorepo. Key differentiator: provides runtime type checking akin to TypeScript's emitDecoratorMetadata, useful in testing and dynamic type validation. Lightweight with no runtime dependencies.

npm install rtts_assert
INSTALL
IMPORT
SIG · RTTS_ASSERT
R
rtts_assert
testingjavascriptv2.0.0-alpha.37
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

assert
import { assert } from 'rtts_assert';
const assert = require('rtts_assert');
ESM-only since v2; no CommonJS support.
assert.type
assert.type(value, Type);
assert(value, Type);
assert.type requires two args; direct assert() with one arg is different (returns an assertion object).
assert.define
assert.define('MyType', function(value) { ... });
assert.define(MyType, function(value) { ... });
First argument must be a string name, not a class/function.

Shows basic type assertion, value assertion, and custom type definition.

import { assert } from 'rtts_assert'; assert.type('hello', String); // passes assert.type(42, String); // throws: Expected String, got Number. const value = 'test'; assert(value).is(String); // passes assert(value).is(Number); // throws assert.define('Email', function(value) { assert(value).is(String); if (value.indexOf('@') === -1) { assert.fail('must contain @'); } }); assert.type('user@example.com', Email); // passes assert.type('invalid', Email); // throws: must contain @
Debug
Known issues
breakingassert.argumentTypes is deprecated and removed in v2; use assert.type instead.
fix
Replace assert.argumentTypes(arg1, Type, arg2, Type) with individual assert.type calls.
affects: >=2.0.0
deprecatedES5 build script es5build.js is no longer maintained.
fix
Use a modern bundler (e.g., esbuild, Webpack) to transpile ES6 sources.
affects: >=2.0.0
gotchaassert(value).is(...) returns an assertion object, not a boolean; must be called as a statement.
fix
Do not assign the result: use assert(value).is(Type) without assignment.
affects: *
gotchaCustom types defined with assert.define must use a string name; using a class name will silently fail.
fix
assert.define('MyClass', fn) instead of assert.define(MyClass, fn).
affects: *
breakingPredefined types like assert.string now require assert.type(value, assert.string) instead of assert(value).is(assert.string) pattern changed.
fix
Use assert.type(value, assert.string) or assert(value).is(assert.string) still works.
affects: >=2.0.0-alpha.37
Errors
Common errors & fixes
TypeError: assert.argumentTypes is not a function
assert.argumentTypes was removed in v2.0.0.
fix
Replace with assert.type(arg1, Type), assert.type(arg2, Type), etc.
Error: Expected argument to be a string but got 'undefined'
assert.define first argument must be a string name, not a type reference.
fix
assert.define('MyType', ..., not assert.define(MyType, ...).
AssertionError: Expected String, got Number.
Value does not match the asserted type.
fix
Check the value and type: assert.type(value, ActualType).
Upgrade
Version history
2.0.0-alpha.37latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
rtts_assert — npm install rtts_assert · libregistry