Gazebo_simulation-Frontend/node_modules/recompose/branch.js

42 lines
1.2 KiB
JavaScript

'use strict';
exports.__esModule = true;
var _react = require('react');
var _setDisplayName = require('./setDisplayName');
var _setDisplayName2 = _interopRequireDefault(_setDisplayName);
var _wrapDisplayName = require('./wrapDisplayName');
var _wrapDisplayName2 = _interopRequireDefault(_wrapDisplayName);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var identity = function identity(Component) {
return Component;
};
var branch = function branch(test, left) {
var right = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : identity;
return function (BaseComponent) {
var leftFactory = void 0;
var rightFactory = void 0;
var Branch = function Branch(props) {
if (test(props)) {
leftFactory = leftFactory || (0, _react.createFactory)(left(BaseComponent));
return leftFactory(props);
}
rightFactory = rightFactory || (0, _react.createFactory)(right(BaseComponent));
return rightFactory(props);
};
if (process.env.NODE_ENV !== 'production') {
return (0, _setDisplayName2.default)((0, _wrapDisplayName2.default)(BaseComponent, 'branch'))(Branch);
}
return Branch;
};
};
exports.default = branch;