1 | (function (global, factory) {
|
2 | if (typeof define === "function" && define.amd) {
|
3 | define(["exports"], factory);
|
4 | } else if (typeof exports !== "undefined") {
|
5 | factory(exports);
|
6 | } else {
|
7 | var mod = {
|
8 | exports: {}
|
9 | };
|
10 | factory(mod.exports);
|
11 | global.mixin = mod.exports;
|
12 | }
|
13 | })(this, function (_exports) {
|
14 | "use strict";
|
15 |
|
16 | Object.defineProperty(_exports, "__esModule", {
|
17 | value: true
|
18 | });
|
19 | _exports.default = mixin;
|
20 |
|
21 | function _classCallCheck(instance, Constructor) {
|
22 | if (!(instance instanceof Constructor)) {
|
23 | throw new TypeError("Cannot call a class as a function");
|
24 | }
|
25 | }
|
26 |
|
27 | function _toConsumableArray(arr) {
|
28 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
|
29 | }
|
30 |
|
31 | function _nonIterableSpread() {
|
32 | throw new TypeError("Invalid attempt to spread non-iterable instance");
|
33 | }
|
34 |
|
35 | function _iterableToArray(iter) {
|
36 | if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
|
37 | }
|
38 |
|
39 | function _arrayWithoutHoles(arr) {
|
40 | if (Array.isArray(arr)) {
|
41 | for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
|
42 | arr2[i] = arr[i];
|
43 | }
|
44 |
|
45 | return arr2;
|
46 | }
|
47 | }
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | |
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | function flatten(a) {
|
62 | return a.reduce(function (result, item) {
|
63 | if (Array.isArray(item)) {
|
64 | result.push.apply(result, _toConsumableArray(flatten(item)));
|
65 | } else {
|
66 | result.push(item);
|
67 | }
|
68 |
|
69 | return result;
|
70 | }, []);
|
71 | }
|
72 | |
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 | |
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | function mixin() {
|
87 | for (var _len = arguments.length, mixinfns = new Array(_len), _key = 0; _key < _len; _key++) {
|
88 | mixinfns[_key] = arguments[_key];
|
89 | }
|
90 |
|
91 | return flatten(mixinfns).reduce(function (Class, mixinfn) {
|
92 | return mixinfn(Class);
|
93 | },
|
94 |
|
95 | function () {
|
96 | function _class() {
|
97 | _classCallCheck(this, _class);
|
98 | }
|
99 |
|
100 | return _class;
|
101 | }());
|
102 | }
|
103 | }); |
\ | No newline at end of file |