(value, type)
| 1722 | var simpleCheckRE = /^(String|Number|Boolean|Function|Symbol)$/; |
| 1723 | |
| 1724 | function 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, |
no test coverage detected