index.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /*istanbul ignore next*/"use strict";
  2. exports.__esModule = true;
  3. exports.is = is;
  4. /*istanbul ignore next*/exports.pullFlag = pullFlag;
  5. var /*istanbul ignore next*/_pull = require("lodash/pull");
  6. /*istanbul ignore next*/
  7. var _pull2 = _interopRequireDefault(_pull);
  8. var /*istanbul ignore next*/_babelTypes = require("babel-types");
  9. /*istanbul ignore next*/
  10. var t = _interopRequireWildcard(_babelTypes);
  11. /*istanbul ignore next*/
  12. 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; } }
  13. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  14. function is(node, flag) {
  15. return t.isRegExpLiteral(node) && node.flags.indexOf(flag) >= 0;
  16. }
  17. function pullFlag(node, flag) {
  18. var flags = node.flags.split("");
  19. if (node.flags.indexOf(flag) < 0) return;
  20. /*istanbul ignore next*/(0, _pull2.default)(flags, flag);
  21. node.flags = flags.join("");
  22. }