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

Function assertType

static/vuejs/vue.common.js:1393–1415  ·  view source on GitHub ↗

* Assert the type of a value

(value, type)

Source from the content-addressed store, hash-verified

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