Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 59x 18x 20x 20x 20x 4x 16x 4x 12x 19x 2x | import is from 'is_js'; /** * Check if an object is a non-empty object */ export function isNonEmptyObject(obj) { return is.object(obj) && is.not.empty(obj); } /** * Return error message for checking the parameters of the constructor. */ export function getConstructorErrorMessage(paramName, value) { return `[Veasy - ${paramName}] Expect: non empty object. Actual: ${value}`; } /** * Type check for 2 parameters of the constructor * */ export function typeCheck(component, schema) { const isComponentValid = isNonEmptyObject(component); const isSchemaValid = isNonEmptyObject(schema); if (!isComponentValid) { throw new Error( getConstructorErrorMessage('Parameter component', component) ); } if (!isSchemaValid) { throw new Error(getConstructorErrorMessage('Parameter schema', schema)); } Object.keys(schema).forEach(prop => { if (!isNonEmptyObject(schema[prop])) { throw new Error( getConstructorErrorMessage(`schema.${prop}`, schema[prop]) ); } }); } |