@learncard/helpers 1.0.20 → 1.1.0

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.
@@ -3989,7 +3989,8 @@ var require_types_cjs_development = __commonJS({
3989
3989
  var BoostRecipientValidator = mod.object({
3990
3990
  to: LCNProfileValidator,
3991
3991
  from: mod.string(),
3992
- received: mod.string().optional()
3992
+ received: mod.string().optional(),
3993
+ uri: mod.string().optional()
3993
3994
  });
3994
3995
  var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
3995
3996
  records: BoostRecipientValidator.array()
@@ -4190,6 +4191,7 @@ var require_dist = __commonJS({
4190
4191
  // src/index.ts
4191
4192
  var src_exports = {};
4192
4193
  __export(src_exports, {
4194
+ RegExpTransformer: () => RegExpTransformer,
4193
4195
  isEncrypted: () => isEncrypted,
4194
4196
  isHex: () => isHex
4195
4197
  });
@@ -4199,3 +4201,30 @@ var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
4199
4201
  var isEncrypted = /* @__PURE__ */ __name((item) => {
4200
4202
  return import_types.JWEValidator.safeParse(item).success;
4201
4203
  }, "isEncrypted");
4204
+ var RegExpTransformer = {
4205
+ serialize(object) {
4206
+ return JSON.stringify(object, (_key, value) => {
4207
+ if (value instanceof RegExp)
4208
+ return value.toString();
4209
+ return value;
4210
+ });
4211
+ },
4212
+ deserialize(object) {
4213
+ if (typeof object !== "string")
4214
+ return object;
4215
+ return JSON.parse(object, (_key, value) => {
4216
+ if (typeof value === "string") {
4217
+ const match = value.match(/^\/(.*)\/([gimsuy]*)$/);
4218
+ if (match) {
4219
+ try {
4220
+ return new RegExp(match[1], match[2]);
4221
+ } catch (error) {
4222
+ console.warn(`Failed to parse RegExp: ${error}`);
4223
+ return value;
4224
+ }
4225
+ }
4226
+ }
4227
+ return value;
4228
+ });
4229
+ }
4230
+ };