@bcts/envelope-pattern 1.0.0-alpha.22 → 1.0.0-alpha.23

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.
package/dist/index.cjs CHANGED
@@ -1,10 +1,9 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let _bcts_dcbor_pattern = require("@bcts/dcbor-pattern");
3
3
  let _bcts_known_values = require("@bcts/known-values");
4
4
  let _bcts_envelope = require("@bcts/envelope");
5
5
  let _bcts_dcbor = require("@bcts/dcbor");
6
6
  let _bcts_dcbor_parse = require("@bcts/dcbor-parse");
7
-
8
7
  //#region src/error.ts
9
8
  /**
10
9
  * Creates a successful result.
@@ -219,7 +218,6 @@ function dcborPatternError(error) {
219
218
  error
220
219
  };
221
220
  }
222
-
223
221
  //#endregion
224
222
  //#region src/format.ts
225
223
  /**
@@ -478,19 +476,27 @@ function formatPathsOpt(paths, opts = defaultFormatPathsOpts()) {
478
476
  function formatPaths(paths) {
479
477
  return formatPathsOpt(paths, defaultFormatPathsOpts());
480
478
  }
481
-
482
479
  //#endregion
483
480
  //#region src/pattern/matcher.ts
484
481
  /**
485
482
  * Default implementations for Matcher methods.
486
483
  */
487
484
  const MatcherDefaults = {
485
+ /**
486
+ * Default implementation of paths() - calls pathsWithCaptures and discards captures.
487
+ */
488
488
  paths(matcher, haystack) {
489
489
  return matcher.pathsWithCaptures(haystack)[0];
490
490
  },
491
+ /**
492
+ * Default implementation of matches() - checks if paths() returns any results.
493
+ */
491
494
  matches(matcher, haystack) {
492
495
  return matcher.paths(haystack).length > 0;
493
496
  },
497
+ /**
498
+ * Default implementation of isComplex() - returns false.
499
+ */
494
500
  isComplex() {
495
501
  return false;
496
502
  }
@@ -578,7 +584,6 @@ function dispatchPatternToString(pattern) {
578
584
  if (patternToStringFn === void 0) throw new Error("Pattern dispatch functions not registered");
579
585
  return patternToStringFn(pattern);
580
586
  }
581
-
582
587
  //#endregion
583
588
  //#region src/pattern/leaf/bool-pattern.ts
584
589
  let createLeafBoolPattern;
@@ -662,7 +667,6 @@ var BoolPattern = class BoolPattern {
662
667
  return hash;
663
668
  }
664
669
  };
665
-
666
670
  //#endregion
667
671
  //#region src/pattern/leaf/null-pattern.ts
668
672
  let createLeafNullPattern;
@@ -731,7 +735,6 @@ var NullPattern = class NullPattern {
731
735
  return 0;
732
736
  }
733
737
  };
734
-
735
738
  //#endregion
736
739
  //#region src/pattern/leaf/number-pattern.ts
737
740
  let createLeafNumberPattern;
@@ -904,7 +907,6 @@ var NumberPattern = class NumberPattern {
904
907
  return hash;
905
908
  }
906
909
  };
907
-
908
910
  //#endregion
909
911
  //#region src/pattern/leaf/text-pattern.ts
910
912
  let createLeafTextPattern;
@@ -1009,7 +1011,6 @@ var TextPattern = class TextPattern {
1009
1011
  return hash;
1010
1012
  }
1011
1013
  };
1012
-
1013
1014
  //#endregion
1014
1015
  //#region src/pattern/leaf/byte-string-pattern.ts
1015
1016
  let createLeafByteStringPattern;
@@ -1120,7 +1121,6 @@ var ByteStringPattern = class ByteStringPattern {
1120
1121
  return hash;
1121
1122
  }
1122
1123
  };
1123
-
1124
1124
  //#endregion
1125
1125
  //#region src/pattern/leaf/date-pattern.ts
1126
1126
  let createLeafDatePattern;
@@ -1235,7 +1235,6 @@ var DatePattern = class DatePattern {
1235
1235
  return hash;
1236
1236
  }
1237
1237
  };
1238
-
1239
1238
  //#endregion
1240
1239
  //#region src/pattern/leaf/array-pattern.ts
1241
1240
  /**
@@ -1417,7 +1416,6 @@ function simpleStringHash$3(str) {
1417
1416
  }
1418
1417
  return hash;
1419
1418
  }
1420
-
1421
1419
  //#endregion
1422
1420
  //#region src/pattern/leaf/map-pattern.ts
1423
1421
  let createLeafMapPattern;
@@ -1508,7 +1506,6 @@ var MapPattern = class MapPattern {
1508
1506
  }
1509
1507
  }
1510
1508
  };
1511
-
1512
1509
  //#endregion
1513
1510
  //#region src/pattern/leaf/known-value-pattern.ts
1514
1511
  let createLeafKnownValuePattern;
@@ -1629,7 +1626,6 @@ function simpleStringHash$2(str) {
1629
1626
  }
1630
1627
  return hash;
1631
1628
  }
1632
-
1633
1629
  //#endregion
1634
1630
  //#region src/pattern/leaf/tagged-pattern.ts
1635
1631
  /**
@@ -1787,7 +1783,6 @@ function simpleStringHash$1(str) {
1787
1783
  }
1788
1784
  return hash;
1789
1785
  }
1790
-
1791
1786
  //#endregion
1792
1787
  //#region src/pattern/leaf/cbor-pattern.ts
1793
1788
  /**
@@ -1996,7 +1991,6 @@ function simpleStringHash(str) {
1996
1991
  }
1997
1992
  return hash;
1998
1993
  }
1999
-
2000
1994
  //#endregion
2001
1995
  //#region src/pattern/leaf/index.ts
2002
1996
  /**
@@ -2198,7 +2192,6 @@ function leafPatternToString(pattern) {
2198
2192
  case "KnownValue": return pattern.pattern.toString();
2199
2193
  }
2200
2194
  }
2201
-
2202
2195
  //#endregion
2203
2196
  //#region src/pattern/structure/leaf-structure-pattern.ts
2204
2197
  let createStructureLeafPattern;
@@ -2251,13 +2244,7 @@ var LeafStructurePattern = class LeafStructurePattern {
2251
2244
  return 0;
2252
2245
  }
2253
2246
  };
2254
-
2255
- //#endregion
2256
- //#region src/pattern/structure/subject-pattern.ts
2257
- let createStructureSubjectPattern;
2258
- function registerSubjectPatternFactory(factory) {
2259
- createStructureSubjectPattern = factory;
2260
- }
2247
+ function registerSubjectPatternFactory(factory) {}
2261
2248
  /**
2262
2249
  * Pattern for matching subjects in envelopes.
2263
2250
  *
@@ -2352,7 +2339,6 @@ var SubjectPattern = class SubjectPattern {
2352
2339
  return this._pattern.type === "Any" ? 0 : 1;
2353
2340
  }
2354
2341
  };
2355
-
2356
2342
  //#endregion
2357
2343
  //#region src/pattern/structure/predicate-pattern.ts
2358
2344
  let createStructurePredicatePattern;
@@ -2450,7 +2436,6 @@ var PredicatePattern = class PredicatePattern {
2450
2436
  return this._pattern.type === "Any" ? 0 : 1;
2451
2437
  }
2452
2438
  };
2453
-
2454
2439
  //#endregion
2455
2440
  //#region src/pattern/structure/object-pattern.ts
2456
2441
  let createStructureObjectPattern;
@@ -2548,7 +2533,6 @@ var ObjectPattern = class ObjectPattern {
2548
2533
  return this._pattern.type === "Any" ? 0 : 1;
2549
2534
  }
2550
2535
  };
2551
-
2552
2536
  //#endregion
2553
2537
  //#region src/pattern/structure/assertions-pattern.ts
2554
2538
  let createStructureAssertionsPattern;
@@ -2706,7 +2690,6 @@ var AssertionsPattern = class AssertionsPattern {
2706
2690
  }
2707
2691
  }
2708
2692
  };
2709
-
2710
2693
  //#endregion
2711
2694
  //#region src/pattern/structure/digest-pattern.ts
2712
2695
  let createStructureDigestPattern;
@@ -2864,7 +2847,6 @@ var DigestPattern = class DigestPattern {
2864
2847
  }
2865
2848
  }
2866
2849
  };
2867
-
2868
2850
  //#endregion
2869
2851
  //#region src/pattern/structure/node-pattern.ts
2870
2852
  let createStructureNodePattern;
@@ -2990,7 +2972,6 @@ var NodePattern = class NodePattern {
2990
2972
  }
2991
2973
  }
2992
2974
  };
2993
-
2994
2975
  //#endregion
2995
2976
  //#region src/pattern/structure/obscured-pattern.ts
2996
2977
  let createStructureObscuredPattern;
@@ -3094,7 +3075,6 @@ var ObscuredPattern = class ObscuredPattern {
3094
3075
  }
3095
3076
  }
3096
3077
  };
3097
-
3098
3078
  //#endregion
3099
3079
  //#region src/pattern/structure/wrapped-pattern.ts
3100
3080
  let createStructureWrappedPattern;
@@ -3237,7 +3217,6 @@ var WrappedPattern = class WrappedPattern {
3237
3217
  return this._pattern.type === "Any" ? 0 : 1;
3238
3218
  }
3239
3219
  };
3240
-
3241
3220
  //#endregion
3242
3221
  //#region src/pattern/structure/index.ts
3243
3222
  /**
@@ -3409,7 +3388,6 @@ function structurePatternToString(pattern) {
3409
3388
  case "Wrapped": return pattern.pattern.toString();
3410
3389
  }
3411
3390
  }
3412
-
3413
3391
  //#endregion
3414
3392
  //#region src/pattern/vm.ts
3415
3393
  let _patternPathsWithCaptures$1;
@@ -4056,7 +4034,6 @@ function compileMetaPattern(pattern, code, literals, captureNames) {
4056
4034
  }
4057
4035
  }
4058
4036
  }
4059
-
4060
4037
  //#endregion
4061
4038
  //#region src/pattern/meta/any-pattern.ts
4062
4039
  let createMetaAnyPattern;
@@ -4108,13 +4085,7 @@ var AnyPattern = class AnyPattern {
4108
4085
  return 0;
4109
4086
  }
4110
4087
  };
4111
-
4112
- //#endregion
4113
- //#region src/pattern/meta/and-pattern.ts
4114
- let createMetaAndPattern;
4115
- function registerAndPatternFactory(factory) {
4116
- createMetaAndPattern = factory;
4117
- }
4088
+ function registerAndPatternFactory(factory) {}
4118
4089
  /**
4119
4090
  * A pattern that matches if all contained patterns match.
4120
4091
  *
@@ -4170,13 +4141,7 @@ var AndPattern = class AndPattern {
4170
4141
  return this._patterns.length;
4171
4142
  }
4172
4143
  };
4173
-
4174
- //#endregion
4175
- //#region src/pattern/meta/or-pattern.ts
4176
- let createMetaOrPattern;
4177
- function registerOrPatternFactory(factory) {
4178
- createMetaOrPattern = factory;
4179
- }
4144
+ function registerOrPatternFactory(factory) {}
4180
4145
  /**
4181
4146
  * A pattern that matches if any contained pattern matches.
4182
4147
  *
@@ -4270,13 +4235,7 @@ var OrPattern = class OrPattern {
4270
4235
  return this._patterns.length;
4271
4236
  }
4272
4237
  };
4273
-
4274
- //#endregion
4275
- //#region src/pattern/meta/not-pattern.ts
4276
- let createMetaNotPattern;
4277
- function registerNotPatternFactory(factory) {
4278
- createMetaNotPattern = factory;
4279
- }
4238
+ function registerNotPatternFactory(factory) {}
4280
4239
  /**
4281
4240
  * A pattern that negates another pattern; matches when the inner pattern does not match.
4282
4241
  *
@@ -4335,13 +4294,7 @@ var NotPattern = class NotPattern {
4335
4294
  return 1;
4336
4295
  }
4337
4296
  };
4338
-
4339
- //#endregion
4340
- //#region src/pattern/meta/capture-pattern.ts
4341
- let createMetaCapturePattern;
4342
- function registerCapturePatternFactory(factory) {
4343
- createMetaCapturePattern = factory;
4344
- }
4297
+ function registerCapturePatternFactory(factory) {}
4345
4298
  /**
4346
4299
  * A pattern that captures a match with a name.
4347
4300
  *
@@ -4420,13 +4373,7 @@ var CapturePattern = class CapturePattern {
4420
4373
  return hash;
4421
4374
  }
4422
4375
  };
4423
-
4424
- //#endregion
4425
- //#region src/pattern/meta/search-pattern.ts
4426
- let createMetaSearchPattern;
4427
- function registerSearchPatternFactory(factory) {
4428
- createMetaSearchPattern = factory;
4429
- }
4376
+ function registerSearchPatternFactory(factory) {}
4430
4377
  /**
4431
4378
  * A pattern that searches the entire envelope tree for matches.
4432
4379
  *
@@ -4553,13 +4500,7 @@ function collectCaptureNames(pattern, out) {
4553
4500
  const p = pattern;
4554
4501
  if (p.collectCaptureNames !== void 0) p.collectCaptureNames(out);
4555
4502
  }
4556
-
4557
- //#endregion
4558
- //#region src/pattern/meta/traverse-pattern.ts
4559
- let createMetaTraversePattern;
4560
- function registerTraversePatternFactory(factory) {
4561
- createMetaTraversePattern = factory;
4562
- }
4503
+ function registerTraversePatternFactory(factory) {}
4563
4504
  let _patternPathsWithCaptures;
4564
4505
  let _patternCompile;
4565
4506
  let _patternIsComplex;
@@ -4653,13 +4594,7 @@ var TraversePattern = class TraversePattern {
4653
4594
  return this.patterns().length;
4654
4595
  }
4655
4596
  };
4656
-
4657
- //#endregion
4658
- //#region src/pattern/meta/group-pattern.ts
4659
- let createMetaGroupPattern;
4660
- function registerGroupPatternFactory(factory) {
4661
- createMetaGroupPattern = factory;
4662
- }
4597
+ function registerGroupPatternFactory(factory) {}
4663
4598
  /**
4664
4599
  * A pattern that matches with repetition.
4665
4600
  *
@@ -4735,7 +4670,6 @@ var GroupPattern = class GroupPattern {
4735
4670
  return this._quantifier.min() * 31 + (this._quantifier.max() ?? 0);
4736
4671
  }
4737
4672
  };
4738
-
4739
4673
  //#endregion
4740
4674
  //#region src/pattern/meta/index.ts
4741
4675
  /**
@@ -4925,7 +4859,6 @@ function collectCaptureNamesFromPattern(pattern, out) {
4925
4859
  const p = pattern;
4926
4860
  if (p.collectCaptureNames !== void 0) p.collectCaptureNames(out);
4927
4861
  }
4928
-
4929
4862
  //#endregion
4930
4863
  //#region src/pattern/dcbor-integration.ts
4931
4864
  /**
@@ -5058,7 +4991,6 @@ function convertMetaPatternToEnvelopePattern(metaPattern, originalPattern) {
5058
4991
  });
5059
4992
  }
5060
4993
  }
5061
-
5062
4994
  //#endregion
5063
4995
  //#region src/pattern/index.ts
5064
4996
  /**
@@ -5594,7 +5526,6 @@ registerPatternDispatchFns({
5594
5526
  toString: patternToString
5595
5527
  });
5596
5528
  registerTraverseDispatchFunctions(patternPathsWithCaptures, patternCompile, patternIsComplex);
5597
-
5598
5529
  //#endregion
5599
5530
  //#region src/parse/token.ts
5600
5531
  /**
@@ -6338,7 +6269,6 @@ var Lexer = class {
6338
6269
  }
6339
6270
  }
6340
6271
  };
6341
-
6342
6272
  //#endregion
6343
6273
  //#region src/parse/index.ts
6344
6274
  /**
@@ -6971,14 +6901,12 @@ function parseUnwrap(lexer) {
6971
6901
  });
6972
6902
  return ok(unwrapMatching(inner.value));
6973
6903
  }
6974
-
6975
6904
  //#endregion
6976
6905
  //#region src/index.ts
6977
6906
  /**
6978
6907
  * Package version.
6979
6908
  */
6980
6909
  const VERSION = "1.0.0-alpha.11";
6981
-
6982
6910
  //#endregion
6983
6911
  exports.AndPattern = AndPattern;
6984
6912
  exports.AnyPattern = AnyPattern;
@@ -6992,11 +6920,11 @@ exports.DatePattern = DatePattern;
6992
6920
  exports.DigestPattern = DigestPattern;
6993
6921
  exports.FormatPathsOptsBuilder = FormatPathsOptsBuilder;
6994
6922
  exports.GroupPattern = GroupPattern;
6995
- Object.defineProperty(exports, 'Interval', {
6996
- enumerable: true,
6997
- get: function () {
6998
- return _bcts_dcbor_pattern.Interval;
6999
- }
6923
+ Object.defineProperty(exports, "Interval", {
6924
+ enumerable: true,
6925
+ get: function() {
6926
+ return _bcts_dcbor_pattern.Interval;
6927
+ }
7000
6928
  });
7001
6929
  exports.KnownValuePattern = KnownValuePattern;
7002
6930
  exports.LeafStructurePattern = LeafStructurePattern;
@@ -7011,17 +6939,17 @@ exports.ObjectPattern = ObjectPattern;
7011
6939
  exports.ObscuredPattern = ObscuredPattern;
7012
6940
  exports.OrPattern = OrPattern;
7013
6941
  exports.PredicatePattern = PredicatePattern;
7014
- Object.defineProperty(exports, 'Quantifier', {
7015
- enumerable: true,
7016
- get: function () {
7017
- return _bcts_dcbor_pattern.Quantifier;
7018
- }
6942
+ Object.defineProperty(exports, "Quantifier", {
6943
+ enumerable: true,
6944
+ get: function() {
6945
+ return _bcts_dcbor_pattern.Quantifier;
6946
+ }
7019
6947
  });
7020
- Object.defineProperty(exports, 'Reluctance', {
7021
- enumerable: true,
7022
- get: function () {
7023
- return _bcts_dcbor_pattern.Reluctance;
7024
- }
6948
+ Object.defineProperty(exports, "Reluctance", {
6949
+ enumerable: true,
6950
+ get: function() {
6951
+ return _bcts_dcbor_pattern.Reluctance;
6952
+ }
7025
6953
  });
7026
6954
  exports.SearchPattern = SearchPattern;
7027
6955
  exports.SubjectPattern = SubjectPattern;
@@ -7230,4 +7158,5 @@ exports.unwrapEnvelope = unwrapEnvelope;
7230
7158
  exports.unwrapMatching = unwrapMatching;
7231
7159
  exports.unwrapOr = unwrapOr;
7232
7160
  exports.wrapped = wrapped;
7161
+
7233
7162
  //# sourceMappingURL=index.cjs.map