index.js 905 B

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