1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
8 |
|
9 | exports.isType = isType;
|
10 | exports.componentType = componentType;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function isType(objectToTest, type) {
|
19 | var o = objectToTest;
|
20 | if ((typeof o === 'undefined' ? 'undefined' : _typeof(o)) === type) {
|
21 | return true;
|
22 | }
|
23 | if (type === String || type === 'string') {
|
24 | return o instanceof String;
|
25 | }
|
26 | if (type === Function || type === 'function') {
|
27 | return o instanceof Function;
|
28 | }
|
29 | if (type === Object || type === 'object') {
|
30 | return o instanceof Object;
|
31 | }
|
32 | if (objectToTest instanceof Function) {
|
33 | var proto = objectToTest;
|
34 | while (proto) {
|
35 | if (proto === type) {
|
36 | return true;
|
37 | }
|
38 | proto = Object.getPrototypeOf(proto);
|
39 | }
|
40 | }
|
41 | return objectToTest instanceof type;
|
42 | }
|
43 |
|
44 | function componentType(componentType) {
|
45 | return function (extensions, onload) {
|
46 | extensions = extensions.filter(function (e) {
|
47 | return isType(e.instance, componentType);
|
48 | });
|
49 | onload(extensions);
|
50 | };
|
51 | } |
\ | No newline at end of file |