@rimbu/deep 0.11.2 → 0.12.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.
Files changed (53) hide show
  1. package/dist/main/deep.js +211 -0
  2. package/dist/main/deep.js.map +1 -0
  3. package/dist/main/index.js +7 -9
  4. package/dist/main/index.js.map +1 -1
  5. package/dist/main/internal.js +6 -4
  6. package/dist/main/internal.js.map +1 -1
  7. package/dist/main/match.js +160 -199
  8. package/dist/main/match.js.map +1 -1
  9. package/dist/main/patch.js +101 -125
  10. package/dist/main/patch.js.map +1 -1
  11. package/dist/main/path.js +109 -62
  12. package/dist/main/path.js.map +1 -1
  13. package/dist/main/protected.js +0 -19
  14. package/dist/main/protected.js.map +1 -1
  15. package/dist/main/selector.js +40 -0
  16. package/dist/main/selector.js.map +1 -0
  17. package/dist/main/tuple.js.map +1 -1
  18. package/dist/module/deep.js +192 -0
  19. package/dist/module/deep.js.map +1 -0
  20. package/dist/module/index.js +9 -1
  21. package/dist/module/index.js.map +1 -1
  22. package/dist/module/internal.js +4 -4
  23. package/dist/module/internal.js.map +1 -1
  24. package/dist/module/match.js +159 -179
  25. package/dist/module/match.js.map +1 -1
  26. package/dist/module/patch.js +91 -112
  27. package/dist/module/patch.js.map +1 -1
  28. package/dist/module/path.js +99 -44
  29. package/dist/module/path.js.map +1 -1
  30. package/dist/module/protected.js +1 -17
  31. package/dist/module/protected.js.map +1 -1
  32. package/dist/module/selector.js +36 -0
  33. package/dist/module/selector.js.map +1 -0
  34. package/dist/module/tuple.js.map +1 -1
  35. package/dist/types/deep.d.ts +284 -0
  36. package/dist/types/index.d.ts +10 -1
  37. package/dist/types/internal.d.ts +7 -4
  38. package/dist/types/match.d.ts +74 -80
  39. package/dist/types/patch.d.ts +57 -50
  40. package/dist/types/path.d.ts +177 -34
  41. package/dist/types/protected.d.ts +1 -16
  42. package/dist/types/selector.d.ts +47 -0
  43. package/dist/types/tuple.d.ts +10 -0
  44. package/package.json +4 -4
  45. package/src/deep.ts +362 -0
  46. package/src/index.ts +14 -10
  47. package/src/internal.ts +7 -4
  48. package/src/match.ts +396 -212
  49. package/src/patch.ts +173 -176
  50. package/src/path.ts +400 -74
  51. package/src/protected.ts +14 -25
  52. package/src/selector.ts +90 -0
  53. package/src/tuple.ts +12 -0
@@ -1,246 +1,207 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.match = exports.Match = void 0;
3
+ exports.match = void 0;
4
4
  var base_1 = require("@rimbu/base");
5
- var Match;
6
- (function (Match) {
7
- /**
8
- * Returns a matcher that returns true if every given `matchItem` matches the given value.
9
- * @typeparam T - the type of value to match
10
- * @typeparam R - the root object type
11
- * @typeparam Q - a utility type for the matcher
12
- * @param matchItems - the match specifications to test
13
- * @example
14
- * ```ts
15
- * const input = { a: 1, b: { c: true, d: 'a' } }
16
- * match(input, Match.every({ a: 1, { c: true } } )) // => true
17
- * match(input, Match.every({ a: 1, { c: false } } )) // => false
18
- * ```
19
- */
20
- function every() {
21
- var matchItems = [];
22
- for (var _i = 0; _i < arguments.length; _i++) {
23
- matchItems[_i] = arguments[_i];
24
- }
25
- return new Every(matchItems);
26
- }
27
- Match.every = every;
28
- /**
29
- * Returns a matcher that returns true if at least one of given `matchItem` matches the given value.
30
- * @typeparam T - the type of value to match
31
- * @typeparam R - the root object type
32
- * @typeparam Q - a utility type for the matcher
33
- * @param matchItems - the match specifications to test
34
- * @example
35
- * ```ts
36
- * const input = { a: 1, b: { c: true, d: 'a' } }
37
- * match(input, Match.some({ a: 5, { c: true } } )) // => true
38
- * match(input, Match.some({ a: 5, { c: false } } )) // => false
39
- * ```
40
- */
41
- function some() {
42
- var matchItems = [];
43
- for (var _i = 0; _i < arguments.length; _i++) {
44
- matchItems[_i] = arguments[_i];
45
- }
46
- return new Some(matchItems);
47
- }
48
- Match.some = some;
49
- /**
50
- * Returns a matcher that returns true if none of given `matchItem` matches the given value.
51
- * @typeparam T - the type of value to match
52
- * @typeparam R - the root object type
53
- * @typeparam Q - a utility type for the matcher
54
- * @param matchItems - the match specifications to test
55
- * @example
56
- * ```ts
57
- * const input = { a: 1, b: { c: true, d: 'a' } }
58
- * match(input, Match.none({ a: 5, { c: true } } )) // => false
59
- * match(input, Match.none({ a: 5, { c: false } } )) // => true
60
- * ```
61
- */
62
- function none() {
63
- var matchItems = [];
64
- for (var _i = 0; _i < arguments.length; _i++) {
65
- matchItems[_i] = arguments[_i];
66
- }
67
- return new None(matchItems);
68
- }
69
- Match.none = none;
70
- /**
71
- * Returns a matcher that returns true if exactly one of given `matchItem` matches the given value.
72
- * @typeparam T - the type of value to match
73
- * @typeparam R - the root object type
74
- * @typeparam Q - a utility type for the matcher
75
- * @param matchItems - the match specifications to test
76
- * @example
77
- * ```ts
78
- * const input = { a: 1, b: { c: true, d: 'a' } }
79
- * match(input, Match.single({ a: 1, { c: true } } )) // => false
80
- * match(input, Match.single({ a: 1, { c: false } } )) // => true
81
- * ```
82
- */
83
- function single() {
84
- var matchItems = [];
85
- for (var _i = 0; _i < arguments.length; _i++) {
86
- matchItems[_i] = arguments[_i];
87
- }
88
- return new Single(matchItems);
89
- }
90
- Match.single = single;
91
- })(Match = exports.Match || (exports.Match = {}));
92
- var Every = /** @class */ (function () {
93
- function Every(matchItems) {
94
- this.matchItems = matchItems;
95
- }
96
- return Every;
97
- }());
98
- var Some = /** @class */ (function () {
99
- function Some(matchItems) {
100
- this.matchItems = matchItems;
101
- }
102
- return Some;
103
- }());
104
- var None = /** @class */ (function () {
105
- function None(matchItems) {
106
- this.matchItems = matchItems;
107
- }
108
- return None;
109
- }());
110
- var Single = /** @class */ (function () {
111
- function Single(matchItems) {
112
- this.matchItems = matchItems;
113
- }
114
- return Single;
115
- }());
116
5
  /**
117
6
  * Returns true if the given `value` object matches the given `matcher`, false otherwise.
118
7
  * @typeparam T - the input value type
119
- * @param value - the value to match (should be a plain object)
8
+ * @typeparam C - utility type
9
+ * @param source - the value to match (should be a plain object)
120
10
  * @param matcher - a matcher object or a function taking the matcher API and returning a match object
11
+ * @param errorCollector - (optional) a string array that can be passed to collect reasons why the match failed
121
12
  * @example
122
13
  * ```ts
123
14
  * const input = { a: 1, b: { c: true, d: 'a' } }
124
15
  * match(input, { a: 1 }) // => true
125
16
  * match(input, { a: 2 }) // => false
126
- * match(input, { a: v => v > 10 }) // => false
17
+ * match(input, { a: (v) => v > 10 }) // => false
127
18
  * match(input, { b: { c: true }}) // => true
128
- * match(input, ({ every }) => every({ a: v => v > 0 }, { b: { c: true } } )) // => true
19
+ * match(input, (['every', { a: (v) => v > 0 }, { b: { c: true } }]) // => true
129
20
  * match(input, { b: { c: (v, parent, root) => v && parent.d.length > 0 && root.a > 0 } })
130
21
  * // => true
131
22
  * ```
132
23
  */
133
- function match(value, matcher) {
134
- if (matcher instanceof Function) {
135
- return matchOptions(value, value, matcher(Match));
136
- }
137
- return matchOptions(value, value, matcher);
24
+ function match(source, matcher, errorCollector) {
25
+ if (errorCollector === void 0) { errorCollector = undefined; }
26
+ return matchEntry(source, source, source, matcher, errorCollector);
138
27
  }
139
28
  exports.match = match;
140
- function matchOptions(value, root, matcher) {
141
- if (matcher instanceof Every) {
142
- var i = -1;
143
- var matchItems = matcher.matchItems;
144
- var len = matchItems.length;
145
- while (++i < len) {
146
- if (!matchOptions(value, root, matchItems[i])) {
147
- return false;
148
- }
149
- }
29
+ /**
30
+ * Match a generic match entry against the given source.
31
+ */
32
+ function matchEntry(source, parent, root, matcher, errorCollector) {
33
+ if (Object.is(source, matcher)) {
34
+ // value and target are exactly the same, always will be true
150
35
  return true;
151
36
  }
152
- if (matcher instanceof Some) {
153
- var i = -1;
154
- var matchItems = matcher.matchItems;
155
- var len = matchItems.length;
156
- while (++i < len) {
157
- if (matchOptions(value, root, matchItems[i])) {
158
- return true;
37
+ if (matcher === null || matcher === undefined) {
38
+ // these matchers can only be direct matches, and previously it was determined that
39
+ // they are not equal
40
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("value ".concat(JSON.stringify(source), " did not match matcher ").concat(matcher));
41
+ return false;
42
+ }
43
+ if (typeof source === 'function') {
44
+ // function source values can only be directly matched
45
+ var result = Object.is(source, matcher);
46
+ if (!result) {
47
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("both value and matcher are functions, but they do not have the same reference");
48
+ }
49
+ return result;
50
+ }
51
+ if (typeof matcher === 'function') {
52
+ // resolve match function first
53
+ var matcherResult = matcher(source, parent, root);
54
+ if (typeof matcherResult === 'boolean') {
55
+ // function resulted in a direct match result
56
+ if (!matcherResult) {
57
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("function matcher returned false for value ".concat(JSON.stringify(source)));
159
58
  }
59
+ return matcherResult;
160
60
  }
161
- return false;
61
+ // function resulted in a value that needs to be further matched
62
+ return matchEntry(source, parent, root, matcherResult, errorCollector);
162
63
  }
163
- if (matcher instanceof None) {
164
- var i = -1;
165
- var matchItems = matcher.matchItems;
166
- var len = matchItems.length;
167
- while (++i < len) {
168
- if (matchOptions(value, root, matchItems[i])) {
64
+ if ((0, base_1.isPlainObj)(source)) {
65
+ // source ia a plain object, can be partially matched
66
+ return matchPlainObj(source, parent, root, matcher, errorCollector);
67
+ }
68
+ if (Array.isArray(source)) {
69
+ // source is an array
70
+ return matchArr(source, root, matcher, errorCollector);
71
+ }
72
+ // already determined above that the source and matcher are not equal
73
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("value ".concat(JSON.stringify(source), " does not match given matcher ").concat(JSON.stringify(matcher)));
74
+ return false;
75
+ }
76
+ /**
77
+ * Match an array matcher against the given source.
78
+ */
79
+ function matchArr(source, root, matcher, errorCollector) {
80
+ if (Array.isArray(matcher)) {
81
+ // directly compare array contents
82
+ var length_1 = source.length;
83
+ if (length_1 !== matcher.length) {
84
+ // if lengths not equal, arrays are not equal
85
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("array lengths are not equal: value length ".concat(source.length, " !== matcher length ").concat(matcher.length));
86
+ return false;
87
+ }
88
+ // loop over arrays, matching every value
89
+ var index = -1;
90
+ while (++index < length_1) {
91
+ if (!Object.is(source[index], matcher[index])) {
92
+ // item did not match, return false
93
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("index ".concat(index, " does not match with value ").concat(JSON.stringify(source[index]), " and matcher ").concat(matcher[index]));
169
94
  return false;
170
95
  }
171
96
  }
97
+ // all items are equal
172
98
  return true;
173
99
  }
174
- if (matcher instanceof Single) {
175
- var i = -1;
176
- var matchItems = matcher.matchItems;
177
- var len = matchItems.length;
178
- var matched = false;
179
- while (++i < len) {
180
- if (matchOptions(value, root, matchItems[i])) {
181
- if (matched) {
182
- return false;
183
- }
184
- matched = true;
185
- }
100
+ // matcher is plain object with index keys
101
+ for (var index in matcher) {
102
+ var matcherAtIndex = matcher[index];
103
+ if (!(index in source)) {
104
+ // source does not have item at given index
105
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("index ".concat(index, " does not exist in source ").concat(JSON.stringify(source), " but should match matcher ").concat(JSON.stringify(matcherAtIndex)));
106
+ return false;
107
+ }
108
+ // match the source item at the given index
109
+ var result = matchEntry(source[index], source, root, matcherAtIndex, errorCollector);
110
+ if (!result) {
111
+ // item did not match
112
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("index ".concat(index, " does not match with value ").concat(JSON.stringify(source[index]), " and matcher ").concat(JSON.stringify(matcherAtIndex)));
113
+ return false;
186
114
  }
187
- return matched;
188
- }
189
- if ((0, base_1.isPlainObj)(matcher)) {
190
- return matchRecord(value, root, matcher);
191
115
  }
192
- return Object.is(value, matcher);
116
+ // all items match
117
+ return true;
193
118
  }
194
- function matchRecord(value, root, matcher) {
195
- if (!(0, base_1.isPlainObj)(matcher)) {
196
- base_1.RimbuError.throwInvalidUsageError('match: to prevent accidental errors, match only supports plain objects as input.');
119
+ /**
120
+ * Match an object matcher against the given source.
121
+ */
122
+ function matchPlainObj(source, parent, root, matcher, errorCollector) {
123
+ if (Array.isArray(matcher)) {
124
+ // the matcher is of compound type
125
+ return matchCompound(source, parent, root, matcher, errorCollector);
197
126
  }
127
+ // partial object props matcher
198
128
  for (var key in matcher) {
199
- if (!(key in value))
129
+ if (!(key in source)) {
130
+ // the source does not have the given key
131
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("key ".concat(key, " is specified in matcher but not present in value ").concat(JSON.stringify(source)));
200
132
  return false;
201
- var matchValue = matcher[key];
202
- var target = value[key];
203
- if (matchValue instanceof Function) {
204
- if (target instanceof Function && Object.is(target, matchValue)) {
205
- return true;
133
+ }
134
+ // match the source value at the given key with the matcher at given key
135
+ var result = matchEntry(source[key], source, root, matcher[key], errorCollector);
136
+ if (!result) {
137
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("key ".concat(key, " does not match in value ").concat(JSON.stringify(source[key]), " with matcher ").concat(JSON.stringify(matcher[key])));
138
+ return false;
139
+ }
140
+ }
141
+ // all properties match
142
+ return true;
143
+ }
144
+ /**
145
+ * Match a compound matcher against the given source.
146
+ */
147
+ function matchCompound(source, parent, root, compound, errorCollector) {
148
+ // first item indicates compound match type
149
+ var matchType = compound[0];
150
+ var length = compound.length;
151
+ // start at index 1
152
+ var index = 0;
153
+ switch (matchType) {
154
+ case 'every': {
155
+ while (++index < length) {
156
+ // if any item does not match, return false
157
+ var result = matchEntry(source, parent, root, compound[index], errorCollector);
158
+ if (!result) {
159
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("in compound \"every\": match at index ".concat(index, " failed"));
160
+ return false;
161
+ }
206
162
  }
207
- var result = matchValue(target, value, root);
208
- if (typeof result === 'boolean') {
163
+ return true;
164
+ }
165
+ case 'none': {
166
+ // if any item matches, return false
167
+ while (++index < length) {
168
+ var result = matchEntry(source, parent, root, compound[index], errorCollector);
209
169
  if (result) {
210
- continue;
170
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("in compound \"none\": match at index ".concat(index, " succeeded"));
171
+ return false;
211
172
  }
212
- return false;
213
- }
214
- if (!matchRecordItem(target, root, result)) {
215
- return false;
216
173
  }
174
+ return true;
217
175
  }
218
- else {
219
- if (!matchRecordItem(target, root, matchValue)) {
220
- return false;
176
+ case 'single': {
177
+ // if not exactly one item matches, return false
178
+ var onePassed = false;
179
+ while (++index < length) {
180
+ var result = matchEntry(source, parent, root, compound[index], errorCollector);
181
+ if (result) {
182
+ if (onePassed) {
183
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("in compound \"single\": multiple matches succeeded");
184
+ return false;
185
+ }
186
+ onePassed = true;
187
+ }
221
188
  }
222
- }
223
- }
224
- return true;
225
- }
226
- function matchRecordItem(value, root, matcher) {
227
- if ((0, base_1.isIterable)(matcher) && (0, base_1.isIterable)(value)) {
228
- var it1 = value[Symbol.iterator]();
229
- var it2 = matcher[Symbol.iterator]();
230
- while (true) {
231
- var v1 = it1.next();
232
- var v2 = it2.next();
233
- if (v1.done !== v2.done || v1.value !== v2.value) {
234
- return false;
189
+ if (!onePassed) {
190
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("in compound \"single\": no matches succeeded");
235
191
  }
236
- if (v1.done) {
237
- return true;
192
+ return onePassed;
193
+ }
194
+ case 'some': {
195
+ // if any item matches, return true
196
+ while (++index < length) {
197
+ var result = matchEntry(source, parent, root, compound[index], errorCollector);
198
+ if (result) {
199
+ return true;
200
+ }
238
201
  }
202
+ errorCollector === null || errorCollector === void 0 ? void 0 : errorCollector.push("in compound \"some\": no matches succeeded");
203
+ return false;
239
204
  }
240
205
  }
241
- if ((0, base_1.isPlainObj)(value)) {
242
- return matchOptions(value, root, matcher);
243
- }
244
- return Object.is(value, matcher);
245
206
  }
246
207
  //# sourceMappingURL=match.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"match.js","sourceRoot":"","sources":["../../src/match.ts"],"names":[],"mappings":";;;AAAA,oCAMqB;AAUrB,IAAiB,KAAK,CAoHrB;AApHD,WAAiB,KAAK;IAuCpB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