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

Function assertType

static/vuejs/vue.runtime.common.js:1389–1411  ·  view source on GitHub ↗

* Assert the type of a value

(value, type)

Source from the content-addressed store, hash-verified

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