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 Aug 19, 2026
·
1 revision
makeRecordGuard is a method that returns a type guard that asserts that the candidate passed in is a record of the form Record<string, T>.
Parameters
singular: (candidate: unknown) => candidate is T
A type guard that the record guard will run against each value in a given object.
Returns
A type guard that asserts that the candidate passed to it is a record of the form Record<string, T>
Examples
import{isNumber,makeRecordGuard}from'@revolutionarygamesco/common'constisNumberRecord=makeRecordGuard<number>(isNumber)isNumberRecord({a: 1,b: 2})// trueisNumberRecord({})// trueisNumberRecord({a: 1,b: '2'})// false; a is a number but b is notisNumberRecord(1)// falseisNumberRecord([1,2])// false