Bootstrap

API writables

testToNormalizeValue

function

testToNormalizeValue<T>(filter): (value) => typeof INVALID_VALUE | T

Check if a value respects a provided type guard.

Type Parameters

T

Parameters

filter

the guard function

Returns

Function

a function that takes a value as input, checks if it respects the type guard and returns INVALID_VALUE otherwise

Parameters

value: any

Returns

typeof INVALID_VALUE | T


typeArray

constant

const typeArray: WritableWithDefaultOptions<any[]>


typeBoolean

constant

const typeBoolean: WritableWithDefaultOptions<boolean>


typeBooleanOrNull

constant

const typeBooleanOrNull: WritableWithDefaultOptions<boolean | null>


typeFunction

constant

const typeFunction: WritableWithDefaultOptions<(...args) => any>


typeHTMLElementOrNull

constant

const typeHTMLElementOrNull: WritableWithDefaultOptions<HTMLElement | null>


typeNumber

constant

const typeNumber: WritableWithDefaultOptions<number>


typeNumberInRangeFactory

function

typeNumberInRangeFactory(min, max, options): WritableWithDefaultOptions<number>

Factory function for creating a type constraint for numbers within a specified range.

Parameters

min: number

The minimum value.

max: number

The maximum value.

options: TypeNumberInRangeOptions = {}

Additional options to customize the behavior.

Returns

WritableWithDefaultOptions<number>

A type guard function that returns the clamp value or INVALID_VALUE depending on the provided options.


TypeNumberInRangeOptions

interface
Properties
strict?

optional strict: boolean

If true, the range checking will be strict, excluding the minimum and maximum values. Default is false.


useClamp?

optional useClamp: boolean

If true, values outside the range will be clamped to the minimum or maximum. Default is true.


typeString

constant

const typeString: WritableWithDefaultOptions<string>