MCPcopy
hub / github.com/fanmingming/live / assertType

Function assertType

m3u8/vue.js:1732–1753  ·  view source on GitHub ↗
(value, type)

Source from the content-addressed store, hash-verified

1730 var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/;
1731
1732 function assertType (value, type) {
1733 var valid;
1734 var expectedType = getType(type);
1735 if (simpleCheckRE.test(expectedType)) {
1736 var t = typeof value;
1737 valid = t === expectedType.toLowerCase();
1738 // for primitive wrapper objects
1739 if (!valid && t === 'object') {
1740 valid = value instanceof type;
1741 }
1742 } else if (expectedType === 'Object') {
1743 valid = isPlainObject(value);
1744 } else if (expectedType === 'Array') {
1745 valid = Array.isArray(value);
1746 } else {
1747 valid = value instanceof type;
1748 }
1749 return {
1750 valid: valid,
1751 expectedType: expectedType
1752 }
1753 }
1754
1755 /**
1756 * Use function string name to check built-in types,

Callers 1

assertPropFunction · 0.85

Calls 2

getTypeFunction · 0.85
isPlainObjectFunction · 0.85

Tested by

no test coverage detected