@hasna/events 0.1.10 → 0.1.11

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/cli/index.js CHANGED
@@ -18,6 +18,19 @@ function getPathValue(input, path) {
18
18
  return;
19
19
  }, input);
20
20
  }
21
+ function getFieldValues(input, path) {
22
+ const values = [];
23
+ const push = (value) => {
24
+ if (!values.some((item) => Object.is(item, value)))
25
+ values.push(value);
26
+ };
27
+ if (path.includes(".") && path in input)
28
+ push(input[path]);
29
+ const nestedValue = getPathValue(input, path);
30
+ if (nestedValue !== undefined || !path.includes("."))
31
+ push(nestedValue);
32
+ return values;
33
+ }
21
34
  function wildcardToRegExp(pattern, options = {}) {
22
35
  let body = "";
23
36
  for (let index = 0;index < pattern.length; index += 1) {
@@ -47,15 +60,15 @@ function matchRecord(input, matcher) {
47
60
  if (!matcher)
48
61
  return true;
49
62
  return Object.entries(matcher).every(([path, expected]) => {
50
- const actual = getPathValue(input, path);
51
- return matchField(actual, expected, path);
63
+ const actualValues = getFieldValues(input, path);
64
+ return matchField(actualValues, expected, path);
52
65
  });
53
66
  }
54
- function matchField(actual, expected, path) {
67
+ function matchField(actualValues, expected, path) {
55
68
  if (isNegativeMatcher(expected)) {
56
- return !matchPositiveField(actual, expected.not, path);
69
+ return !actualValues.some((actual) => matchPositiveField(actual, expected.not, path));
57
70
  }
58
- return matchPositiveField(actual, expected, path);
71
+ return actualValues.some((actual) => matchPositiveField(actual, expected, path));
59
72
  }
60
73
  function matchPositiveField(actual, expected, path) {
61
74
  if (typeof expected === "string" || Array.isArray(expected)) {
package/dist/commander.js CHANGED
@@ -8,6 +8,19 @@ function getPathValue(input, path) {
8
8
  return;
9
9
  }, input);
10
10
  }
11
+ function getFieldValues(input, path) {
12
+ const values = [];
13
+ const push = (value) => {
14
+ if (!values.some((item) => Object.is(item, value)))
15
+ values.push(value);
16
+ };
17
+ if (path.includes(".") && path in input)
18
+ push(input[path]);
19
+ const nestedValue = getPathValue(input, path);
20
+ if (nestedValue !== undefined || !path.includes("."))
21
+ push(nestedValue);
22
+ return values;
23
+ }
11
24
  function wildcardToRegExp(pattern, options = {}) {
12
25
  let body = "";
13
26
  for (let index = 0;index < pattern.length; index += 1) {
@@ -37,15 +50,15 @@ function matchRecord(input, matcher) {
37
50
  if (!matcher)
38
51
  return true;
39
52
  return Object.entries(matcher).every(([path, expected]) => {
40
- const actual = getPathValue(input, path);
41
- return matchField(actual, expected, path);
53
+ const actualValues = getFieldValues(input, path);
54
+ return matchField(actualValues, expected, path);
42
55
  });
43
56
  }
44
- function matchField(actual, expected, path) {
57
+ function matchField(actualValues, expected, path) {
45
58
  if (isNegativeMatcher(expected)) {
46
- return !matchPositiveField(actual, expected.not, path);
59
+ return !actualValues.some((actual) => matchPositiveField(actual, expected.not, path));
47
60
  }
48
- return matchPositiveField(actual, expected, path);
61
+ return actualValues.some((actual) => matchPositiveField(actual, expected, path));
49
62
  }
50
63
  function matchPositiveField(actual, expected, path) {
51
64
  if (typeof expected === "string" || Array.isArray(expected)) {
package/dist/filter.js CHANGED
@@ -8,6 +8,19 @@ function getPathValue(input, path) {
8
8
  return;
9
9
  }, input);
10
10
  }
11
+ function getFieldValues(input, path) {
12
+ const values = [];
13
+ const push = (value) => {
14
+ if (!values.some((item) => Object.is(item, value)))
15
+ values.push(value);
16
+ };
17
+ if (path.includes(".") && path in input)
18
+ push(input[path]);
19
+ const nestedValue = getPathValue(input, path);
20
+ if (nestedValue !== undefined || !path.includes("."))
21
+ push(nestedValue);
22
+ return values;
23
+ }
11
24
  function wildcardToRegExp(pattern, options = {}) {
12
25
  let body = "";
13
26
  for (let index = 0;index < pattern.length; index += 1) {
@@ -37,15 +50,15 @@ function matchRecord(input, matcher) {
37
50
  if (!matcher)
38
51
  return true;
39
52
  return Object.entries(matcher).every(([path, expected]) => {
40
- const actual = getPathValue(input, path);
41
- return matchField(actual, expected, path);
53
+ const actualValues = getFieldValues(input, path);
54
+ return matchField(actualValues, expected, path);
42
55
  });
43
56
  }
44
- function matchField(actual, expected, path) {
57
+ function matchField(actualValues, expected, path) {
45
58
  if (isNegativeMatcher(expected)) {
46
- return !matchPositiveField(actual, expected.not, path);
59
+ return !actualValues.some((actual) => matchPositiveField(actual, expected.not, path));
47
60
  }
48
- return matchPositiveField(actual, expected, path);
61
+ return actualValues.some((actual) => matchPositiveField(actual, expected, path));
49
62
  }
50
63
  function matchPositiveField(actual, expected, path) {
51
64
  if (typeof expected === "string" || Array.isArray(expected)) {
package/dist/index.js CHANGED
@@ -8,6 +8,19 @@ function getPathValue(input, path) {
8
8
  return;
9
9
  }, input);
10
10
  }
11
+ function getFieldValues(input, path) {
12
+ const values = [];
13
+ const push = (value) => {
14
+ if (!values.some((item) => Object.is(item, value)))
15
+ values.push(value);
16
+ };
17
+ if (path.includes(".") && path in input)
18
+ push(input[path]);
19
+ const nestedValue = getPathValue(input, path);
20
+ if (nestedValue !== undefined || !path.includes("."))
21
+ push(nestedValue);
22
+ return values;
23
+ }
11
24
  function wildcardToRegExp(pattern, options = {}) {
12
25
  let body = "";
13
26
  for (let index = 0;index < pattern.length; index += 1) {
@@ -37,15 +50,15 @@ function matchRecord(input, matcher) {
37
50
  if (!matcher)
38
51
  return true;
39
52
  return Object.entries(matcher).every(([path, expected]) => {
40
- const actual = getPathValue(input, path);
41
- return matchField(actual, expected, path);
53
+ const actualValues = getFieldValues(input, path);
54
+ return matchField(actualValues, expected, path);
42
55
  });
43
56
  }
44
- function matchField(actual, expected, path) {
57
+ function matchField(actualValues, expected, path) {
45
58
  if (isNegativeMatcher(expected)) {
46
- return !matchPositiveField(actual, expected.not, path);
59
+ return !actualValues.some((actual) => matchPositiveField(actual, expected.not, path));
47
60
  }
48
- return matchPositiveField(actual, expected, path);
61
+ return actualValues.some((actual) => matchPositiveField(actual, expected, path));
49
62
  }
50
63
  function matchPositiveField(actual, expected, path) {
51
64
  if (typeof expected === "string" || Array.isArray(expected)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/events",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Shared event envelopes, local subscriptions, and webhook delivery for Hasna open-source apps",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",