You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Jason Godesky edited this page Jul 11, 2026
·
1 revision
makeArrayGuard is a method that returns a type guard that asserts that the candidate passed in is an array and that each element of that array matches the type guard provided.
Parameters
singular: (candidate: unknown) => candidate is T
A type guard that the array guard will run against each element in a given array.
Returns
A type guard that asserts that the candidate passed to it is an array and that each element of that array passes the singular type guard passed to it.
Examples
import{isNumber,isString,makeArrayGuard}from'@revolutionarygamesco/common'// This is literally how we define our isNumberArray method.constisNumberArray: (candidate: unknown)=>candidate is number[]=makeArrayGuard<number>(isNumber)// This is literally how we define our isStringArray method.constisStringArray: (candidate: unknown)=>candidate is number[]=makeArrayGuard<string>(isString)