/* @flow */

import pull from "lodash/array/pull";
import * as t from "babel-types";

export function is(node: Object, flag: string): boolean {
  return t.isRegexLiteral(node) && node.flags.indexOf(flag) >= 0;
}

export function pullFlag(node: Object, flag: string) {
  let flags = node.flags.split("");
  if (node.flags.indexOf(flag) < 0) return;
  pull(flags, flag);
  node.flags = flags.join("");
}
