import { PlainObject, Predicate } from '../types' import { isObject } from '../predicates' export const record = ( keyPredicate: Predicate, valuePredicate: Predicate, ) => (value: unknown): value is Record => { let isValid = isObject(value) if (isValid) { for (const key in value as PlainObject) { if (Object.hasOwnProperty.call(value, key)) { isValid = keyPredicate(key) && valuePredicate((value as PlainObject)[key]) if (!isValid) { break } } } } return isValid }