Skip to content

assertcheck v0.6.0


assertcheck / Checker

Class: Checker<T> ​

Defined in: src/checker.ts:51

Base class holding the wrapped value. Exposes tap for inline side-effects without breaking the chain.

Extended by ​

Type Parameters ​

Type ParameterDescription
TThe type of the wrapped value.

Constructors ​

Constructor ​

ts
new Checker<T>(value): Checker<T>;

Defined in: src/checker.ts:52

Parameters ​

ParameterType
valueT

Returns ​

Checker<T>

Properties ​

PropertyModifierTypeDefined in
valuereadonlyTsrc/checker.ts:52

Methods ​

narrow() ​

ts
protected narrow<U, A>(fn, ...args): U;

Defined in: src/checker.ts:80

Same as run, but re-types the checker after a narrowing assertion.

Type Parameters ​

Type Parameter
U
A extends unknown[]

Parameters ​

ParameterType
fn(v, ...args) => void
...argsA

Returns ​

U


run() ​

ts
protected run<A>(fn, ...args): this;

Defined in: src/checker.ts:74

Applies an assert.* function to the wrapped value, then returns this for chaining.

Type Parameters ​

Type Parameter
A extends unknown[]

Parameters ​

ParameterType
fn(v, ...args) => void
...argsA

Returns ​

this


tap() ​

ts
tap(fn): this;

Defined in: src/checker.ts:68

Runs a side-effect function with the wrapped value and returns this to allow chaining. Useful for logging or debugging mid-chain.

Parameters ​

ParameterTypeDescription
fn(v) => voidA function that receives the wrapped value.

Returns ​

this

The current checker instance for chaining.

Example ​

ts
check(orders)
  .tap(v => console.log("orders:", v))
  .all(o => o.status === "paid")

Released under the Apache 2.0 License. Built by Vagabond Studio — senior-only for growing companies.