index.js 677 B

1234567891011121314151617181920212223242526
  1. import { SYMBOL_REGEXP } from '../helper/symbol';
  2. export class RegExp {
  3. constructor({ regexp, options }) {
  4. if (!regexp) {
  5. throw new TypeError('regexp must be a string');
  6. }
  7. this.$regularExpression = {
  8. pattern: regexp || '',
  9. options: options || ''
  10. };
  11. }
  12. parse() {
  13. return {
  14. $regularExpression: {
  15. pattern: this.$regularExpression.pattern,
  16. options: this.$regularExpression.options
  17. }
  18. };
  19. }
  20. get _internalType() {
  21. return SYMBOL_REGEXP;
  22. }
  23. }
  24. export function RegExpConstructor(param) {
  25. return new RegExp(param);
  26. }