1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8 |
|
9 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
10 |
|
11 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
12 |
|
13 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
14 |
|
15 | /**
|
16 | * A Command extends the Function class by generating Javascript
|
17 | * and passing it directly to the Function (super) constructor.
|
18 | */
|
19 | var commandCount = 0;
|
20 |
|
21 | var Command = exports.Command = function (_Function) {
|
22 | _inherits(Command, _Function);
|
23 |
|
24 | _createClass(Command, null, [{
|
25 | key: 'count',
|
26 | value: function (_count) {
|
27 | function count() {
|
28 | return _count.apply(this, arguments);
|
29 | }
|
30 |
|
31 | count.toString = function () {
|
32 | return _count.toString();
|
33 | };
|
34 |
|
35 | return count;
|
36 | }(function () {
|
37 | return count;
|
38 | })
|
39 | }, {
|
40 | key: 'codegen',
|
41 | value: function codegen(fn) {
|
42 | if ('function' != typeof fn) {
|
43 | throw new TypeError("Expecting a function");
|
44 | } else {
|
45 | return '"use strict"; return (' + String(fn) + ').apply(this, arguments);';
|
46 | }
|
47 | }
|
48 | }]);
|
49 |
|
50 | function Command(fn) {
|
51 | var _ret;
|
52 |
|
53 | _classCallCheck(this, Command);
|
54 |
|
55 | if ('function' != typeof fn) {
|
56 | throw new TypeError("Command constructor expects a function.");
|
57 | }
|
58 | // initialize underlying function wrap
|
59 |
|
60 | var _this = _possibleConstructorReturn(this, (Command.__proto__ || Object.getPrototypeOf(Command)).call(this, Command.codegen(function wrap(fn) {
|
61 | return fn.apply(fn, Array.prototype.slice.call(arguments, 1));
|
62 | })));
|
63 |
|
64 | var exec = function exec() {
|
65 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
66 | args[_key] = arguments[_key];
|
67 | }
|
68 |
|
69 | return _this.apply(undefined, [fn].concat(args));
|
70 | };
|
71 | _this.constructor = exec.constructor = Command;
|
72 | void commandCount++;
|
73 | return _ret = Object.assign(exec, { 'this': _this }), _possibleConstructorReturn(_this, _ret);
|
74 | }
|
75 |
|
76 | return Command;
|
77 | }(Function);
|
78 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb3JlL2NvbW1hbmQuanMiXSwibmFtZXMiOlsiY29tbWFuZENvdW50IiwiQ29tbWFuZCIsImNvdW50IiwiZm4iLCJUeXBlRXJyb3IiLCJTdHJpbmciLCJjb2RlZ2VuIiwid3JhcCIsImFwcGx5IiwiQXJyYXkiLCJwcm90b3R5cGUiLCJzbGljZSIsImNhbGwiLCJhcmd1bWVudHMiLCJleGVjIiwiYXJncyIsImNvbnN0cnVjdG9yIiwiT2JqZWN0IiwiYXNzaWduIiwiRnVuY3Rpb24iXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7O0FBQUE7Ozs7QUFJQSxJQUFJQSxlQUFlLENBQW5COztJQUNhQyxPLFdBQUFBLE87Ozs7Ozs7Ozs7Ozs7OztrQkFDS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