* Throws if obj is not of given type.
(obj, type)
| 197 | * Throws if obj is not of given type. |
| 198 | */ |
| 199 | function assertInstanceof(obj, type) { |
| 200 | if (!(obj instanceof type)) { |
| 201 | var actualTypeName = null; |
| 202 | var actualConstructor = Object.getPrototypeOf(obj).constructor; |
| 203 | if (typeof actualConstructor == "function") { |
| 204 | actualTypeName = actualConstructor.name || String(actualConstructor); |
| 205 | } |
| 206 | throw new Error('Object <' + obj + '> is not an instance of <' + |
| 207 | (type.name || type) + '>' + |
| 208 | (actualTypeName ? ' but of < ' + actualTypeName + '>' : '')); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Split a BCP 47 language tag into locale and extension. |
searching dependent graphs…