question

Usage: question(predForm)

Returns a regex op that matches zero or one value matching pred. Produces a single value (not a collection) if matched.

Source

Example:

const s = require('speculaas');
const {isInteger, isOdd} = s.utils;

s.def('::odd?', s.and(isInteger, isOdd));
const odds = s.question('::odd?');

s.isValid(odds, [1]);
// true

s.isValid(odds, [1, 3]);
// false

results matching ""

    No results matching ""