MCPcopy
hub / github.com/vaxilu/x-ui / assertType

Function assertType

web/assets/vue@2.6.12/vue.runtime.esm.js:1724–1745  ·  view source on GitHub ↗
(value, type)

Source from the content-addressed store, hash-verified

1722var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
1723
1724function assertType (value, type) {
1725 var valid;
1726 var expectedType = getType(type);
1727 if (simpleCheckRE.test(expectedType)) {
1728 var t = typeof value;
1729 valid = t === expectedType.toLowerCase();
1730 // for primitive wrapper objects
1731 if (!valid && t === 'object') {
1732 valid = value instanceof type;
1733 }
1734 } else if (expectedType === 'Object') {
1735 valid = isPlainObject(value);
1736 } else if (expectedType === 'Array') {
1737 valid = Array.isArray(value);
1738 } else {
1739 valid = value instanceof type;
1740 }
1741 return {
1742 valid: valid,
1743 expectedType: expectedType
1744 }
1745}
1746
1747/**
1748 * 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