MCPcopy Index your code
hub / github.com/TruthHun/BookStack / assertType

Function assertType

static/vuejs/vue.js:1397–1419  ·  view source on GitHub ↗

* Assert the type of a value

(value, type)

Source from the content-addressed store, hash-verified

1395 * Assert the type of a value
1396 */
1397function assertType (value, type) {
1398 var valid;
1399 var expectedType = getType(type);
1400 if (expectedType === 'String') {
1401 valid = typeof value === (expectedType = 'string');
1402 } else if (expectedType === 'Number') {
1403 valid = typeof value === (expectedType = 'number');
1404 } else if (expectedType === 'Boolean') {
1405 valid = typeof value === (expectedType = 'boolean');
1406 } else if (expectedType === 'Function') {
1407 valid = typeof value === (expectedType = 'function');
1408 } else if (expectedType === 'Object') {
1409 valid = isPlainObject(value);
1410 } else if (expectedType === 'Array') {
1411 valid = Array.isArray(value);
1412 } else {
1413 valid = value instanceof type;
1414 }
1415 return {
1416 valid: valid,
1417 expectedType: expectedType
1418 }
1419}
1420
1421/**
1422 * 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