We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
makeTupleGuard is a method that returns a type guard that asserts that the candidate passed in is a tuple of a precise length with precise types.
...guards: Guards<T>
The type guards that should be applied to each member of the tuple in order.
A type guard that asserts that the candidate passed to it is a tuple that tests each element against each guard provided, in the order provided.
import { isNumber, isString, makeTupleGuard } from '@revolutionarygamesco/common' const isNumStr = makeTupleGuard(isNumber, isString) isNumStr([42, 'hello!']) // true isNumStr(['hello!', 42]) // false isNumStr([42, 'hello!', true]) // false isNumStr([]) // false isNumStr([42]) // false isNumStr(['hello!]) // false isNumStr(42) // false isNumStr('hello!) // false isNumStr({ num: 42, str: 'hello!' }) // false