MCPcopy Create free account
hub / github.com/TruthHun/BookStack / assertType

Function assertType

static/vuejs/vue.esm.js:1391–1413  ·  view source on GitHub ↗

* Assert the type of a value

(value, type)

Source from the content-addressed store, hash-verified

1389 * Assert the type of a value
1390 */
1391function assertType (value, type) {
1392 var valid;
1393 var expectedType = getType(type);
1394 if (expectedType === 'String') {
1395 valid = typeof value === (expectedType = 'string');
1396 } else if (expectedType === 'Number') {
1397 valid = typeof value === (expectedType = 'number');
1398 } else if (expectedType === 'Boolean') {
1399 valid = typeof value === (expectedType = 'boolean');
1400 } else if (expectedType === 'Function') {
1401 valid = typeof value === (expectedType = 'function');
1402 } else if (expectedType === 'Object') {
1403 valid = isPlainObject(value);
1404 } else if (expectedType === 'Array') {
1405 valid = Array.isArray(value);
1406 } else {
1407 valid = value instanceof type;
1408 }
1409 return {
1410 valid: valid,
1411 expectedType: expectedType
1412 }
1413}
1414
1415/**
1416 * Use function string name to check built-in types,

Callers 1

assertPropFunction · 0.70

Calls 2

getTypeFunction · 0.70
isPlainObjectFunction · 0.70

Tested by

no test coverage detected