1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /*istanbul ignore next*/"use strict";
- exports.__esModule = true;
- var _getIterator2 = require("babel-runtime/core-js/get-iterator");
- var _getIterator3 = _interopRequireDefault(_getIterator2);
- exports.default = bindifyDecorators;
- var /*istanbul ignore next*/_babelTypes = require("babel-types");
- /*istanbul ignore next*/
- var t = _interopRequireWildcard(_babelTypes);
- /*istanbul ignore next*/
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
- function bindifyDecorators(decorators) {
- for ( /*istanbul ignore next*/var _iterator = decorators, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
- /*istanbul ignore next*/
- var _ref;
- if (_isArray) {
- if (_i >= _iterator.length) break;
- _ref = _iterator[_i++];
- } else {
- _i = _iterator.next();
- if (_i.done) break;
- _ref = _i.value;
- }
- var decoratorPath = _ref;
- var decorator = decoratorPath.node;
- var expression = decorator.expression;
- if (!t.isMemberExpression(expression)) continue;
- var temp = decoratorPath.scope.maybeGenerateMemoised(expression.object);
- var ref = /*istanbul ignore next*/void 0;
- var nodes = [];
- if (temp) {
- ref = temp;
- nodes.push(t.assignmentExpression("=", temp, expression.object));
- } else {
- ref = expression.object;
- }
- nodes.push(t.callExpression(t.memberExpression(t.memberExpression(ref, expression.property, expression.computed), t.identifier("bind")), [ref]));
- if (nodes.length === 1) {
- decorator.expression = nodes[0];
- } else {
- decorator.expression = t.sequenceExpression(nodes);
- }
- }
- }
- /*istanbul ignore next*/module.exports = exports["default"];
|