The source iterable.
A function to test each element for a condition. If false, an error will be thrown.
Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.
const items = [1, 2, '3'];
const sum = from(items).assert(x => typeof x === 'number', 'Should be number').sum(); // throws due to '3'
TSource The type of source elements.
A sequence with source elements in their original order.
The source iterable.
A function to test each element for a condition. If false, an error will be thrown.
The message to use for thrown errors.
Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.
class MyError extends Error {}
const items = [1, 2, '3'];
const sum = from(items).assert(x => typeof x === 'number', MyError).sum(); // throws instance of MyError due to '3'
TSource The type of source elements.
TError The type of error to be thrown.
A sequence with source elements in their original order.
The source iterable.
A function to test each element for a condition. If false, an error will be thrown.
Type of error to throw.
Optional
message: stringTests a sequence with a given predicate. An error will be thrown if any element fails the sequence.
class MyError extends Error {}
const items = [1, 2, '3'];
const sum = from(items).assert(x => typeof x === 'number', 'Must be number', MyError).sum(); // throws instance of MyError with message due to '3'
TSource The type of source elements.
TError The type of error to be thrown.
A sequence with source elements in their original order.
The source iterable.
A function to test each element for a condition. If false, an error will be thrown.
The message to use for thrown errors.
Type of error to throw.
Optional
message: stringGenerated using TypeDoc
Tests a sequence with a given predicate. An error will be thrown if any element fails the sequence.
Example
Typeparam
TSource The type of source elements.
Returns
A sequence with source elements in their original order.