(value, type)
| 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, |
no test coverage detected