Skip to content

Endo API documentation - v0.2.0 / Exports / @endo/common / ident-checker

Module: ident-checker

Table of contents

Type Aliases

Functions

Type Aliases

Checker

Ƭ Checker: (cond: boolean, details?: ses) => boolean

Internal to a useful pattern for writing checking logic (a "checkFoo" function) that can be used to implement a predicate (an "isFoo" function) or a validator (an "assertFoo" function).

  • A predicate ideally only returns true or false and rarely throws.
  • A validator throws an informative diagnostic when the predicate would have returned false, and simply returns undefined normally when the predicate would have returned true.
  • The internal checking function that they share is parameterized by a Checker that determines how to proceed with a failure condition. Predicates pass in an identity function as checker. Validators pass in assertChecker which is a trivial wrapper around assert.

See the various uses for good examples.

Type declaration

▸ (cond, details?): boolean

Parameters
NameType
condboolean
details?ses
Returns

boolean

Defined in

ident-checker.js:5

Functions

identChecker

identChecker(cond, details?): boolean

In the assertFoo/isFoo/checkFoo pattern, checkFoo has a check parameter of type Checker. assertFoo calls checkFoo passes assertChecker as the check argument. isFoo passes identChecker as the check argument. identChecker acts precisely like an identity function, but is typed as a Checker to indicate its intended use.

Parameters

NameType
condboolean
details?Details

Returns

boolean

Defined in

ident-checker.js:35