UNPKG

668 BJavaScriptView Raw
1import is from '@sindresorhus/is';
2import test from '../test.js';
3const ofTypeDeep = (object, predicate) => {
4 if (!is.plainObject(object)) {
5 test(object, 'deep values', predicate, false);
6 return true;
7 }
8 return Object.values(object).every(value => ofTypeDeep(value, predicate));
9};
10/**
11Test all the values in the object against a provided predicate.
12
13@hidden
14
15@param predicate - Predicate to test every value in the given object against.
16*/
17const ofTypeDeepSafe = (object, predicate) => {
18 try {
19 return ofTypeDeep(object, predicate);
20 }
21 catch (error) {
22 return error.message;
23 }
24};
25export default ofTypeDeepSafe;