@lousy-agents/cli 2.5.0 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5610,6 +5610,7 @@ exports["default"] = def;
5610
5610
 
5611
5611
  Object.defineProperty(exports, "__esModule", ({ value: true }));
5612
5612
  const code_1 = __webpack_require__(5765);
5613
+ const util_1 = __webpack_require__(4227);
5613
5614
  const codegen_1 = __webpack_require__(9029);
5614
5615
  const error = {
5615
5616
  message: ({ schemaCode }) => (0, codegen_1.str) `must match pattern "${schemaCode}"`,
@@ -5622,11 +5623,19 @@ const def = {
5622
5623
  $data: true,
5623
5624
  error,
5624
5625
  code(cxt) {
5625
- const { data, $data, schema, schemaCode, it } = cxt;
5626
- // TODO regexp should be wrapped in try/catchs
5626
+ const { gen, data, $data, schema, schemaCode, it } = cxt;
5627
5627
  const u = it.opts.unicodeRegExp ? "u" : "";
5628
- const regExp = $data ? (0, codegen_1._) `(new RegExp(${schemaCode}, ${u}))` : (0, code_1.usePattern)(cxt, schema);
5629
- cxt.fail$data((0, codegen_1._) `!${regExp}.test(${data})`);
5628
+ if ($data) {
5629
+ const { regExp } = it.opts.code;
5630
+ const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._) `new RegExp` : (0, util_1.useFunc)(gen, regExp);
5631
+ const valid = gen.let("valid");
5632
+ gen.try(() => gen.assign(valid, (0, codegen_1._) `${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
5633
+ cxt.fail$data((0, codegen_1._) `!${valid}`);
5634
+ }
5635
+ else {
5636
+ const regExp = (0, code_1.usePattern)(cxt, schema);
5637
+ cxt.fail$data((0, codegen_1._) `!${regExp}.test(${data})`);
5638
+ }
5630
5639
  },
5631
5640
  };
5632
5641
  exports["default"] = def;