feathers-utils 2.1.1 → 2.1.3

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
@@ -16,7 +16,7 @@ const _debounce = require('lodash/debounce.js');
16
16
  const _isObject = require('lodash/isObject.js');
17
17
 
18
18
  function mergeArrays(targetArr, sourceArr, handle, prependKey, actionOnEmptyIntersect) {
19
- if (!sourceArr || !targetArr) {
19
+ if (!sourceArr && !targetArr) {
20
20
  return;
21
21
  }
22
22
  if (handle === "target") {
@@ -33,9 +33,9 @@ function mergeArrays(targetArr, sourceArr, handle, prependKey, actionOnEmptyInte
33
33
  const arr = targetArr.concat(sourceArr);
34
34
  return [...new Set(arr)];
35
35
  } else if (handle === "intersect" || handle === "intersectOrFull") {
36
- const targetIsArray = !targetArr || !Array.isArray(targetArr);
37
- const sourceIsArray = !sourceArr || !Array.isArray(sourceArr);
38
- if ((targetIsArray || sourceIsArray) && handle === "intersect") {
36
+ const targetIsNotArray = !targetArr || !Array.isArray(targetArr);
37
+ const sourceIsNotArray = !sourceArr || !Array.isArray(sourceArr);
38
+ if ((targetIsNotArray || sourceIsNotArray) && handle === "intersect") {
39
39
  if (actionOnEmptyIntersect) {
40
40
  actionOnEmptyIntersect(
41
41
  targetArr,
@@ -45,8 +45,8 @@ function mergeArrays(targetArr, sourceArr, handle, prependKey, actionOnEmptyInte
45
45
  }
46
46
  return;
47
47
  }
48
- if (handle === "intersectOrFull") {
49
- const val = !targetIsArray ? targetArr : sourceArr;
48
+ if (targetIsNotArray || sourceIsNotArray) {
49
+ const val = !targetIsNotArray ? targetArr : sourceArr;
50
50
  return val;
51
51
  }
52
52
  return targetArr.filter((val) => sourceArr.includes(val));
package/dist/index.d.ts CHANGED
@@ -202,7 +202,7 @@ type ShouldSkipOptions = {
202
202
  /**
203
203
  * util to detect if a hook should be skipped
204
204
  */
205
- declare const shouldSkip: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>, O extends ShouldSkipOptions = ShouldSkipOptions>(hookName: string, context: H, options?: O | undefined) => boolean;
205
+ declare const shouldSkip: <H extends HookContext<_feathersjs_feathers.Application<any, any>, any> = HookContext<_feathersjs_feathers.Application<any, any>, any>>(hookName: string, context: H, options?: ShouldSkipOptions) => boolean;
206
206
 
207
207
  /**
208
208
  * util to validate a query for operators
package/dist/index.mjs CHANGED
@@ -14,7 +14,7 @@ import _debounce from 'lodash/debounce.js';
14
14
  import _isObject from 'lodash/isObject.js';
15
15
 
16
16
  function mergeArrays(targetArr, sourceArr, handle, prependKey, actionOnEmptyIntersect) {
17
- if (!sourceArr || !targetArr) {
17
+ if (!sourceArr && !targetArr) {
18
18
  return;
19
19
  }
20
20
  if (handle === "target") {
@@ -31,9 +31,9 @@ function mergeArrays(targetArr, sourceArr, handle, prependKey, actionOnEmptyInte
31
31
  const arr = targetArr.concat(sourceArr);
32
32
  return [...new Set(arr)];
33
33
  } else if (handle === "intersect" || handle === "intersectOrFull") {
34
- const targetIsArray = !targetArr || !Array.isArray(targetArr);
35
- const sourceIsArray = !sourceArr || !Array.isArray(sourceArr);
36
- if ((targetIsArray || sourceIsArray) && handle === "intersect") {
34
+ const targetIsNotArray = !targetArr || !Array.isArray(targetArr);
35
+ const sourceIsNotArray = !sourceArr || !Array.isArray(sourceArr);
36
+ if ((targetIsNotArray || sourceIsNotArray) && handle === "intersect") {
37
37
  if (actionOnEmptyIntersect) {
38
38
  actionOnEmptyIntersect(
39
39
  targetArr,
@@ -43,8 +43,8 @@ function mergeArrays(targetArr, sourceArr, handle, prependKey, actionOnEmptyInte
43
43
  }
44
44
  return;
45
45
  }
46
- if (handle === "intersectOrFull") {
47
- const val = !targetIsArray ? targetArr : sourceArr;
46
+ if (targetIsNotArray || sourceIsNotArray) {
47
+ const val = !targetIsNotArray ? targetArr : sourceArr;
48
48
  return val;
49
49
  }
50
50
  return targetArr.filter((val) => sourceArr.includes(val));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feathers-utils",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Some utils for projects using '@feathersjs/feathers'",
5
5
  "author": "fratzinger",
6
6
  "repository": {
@@ -39,36 +39,36 @@
39
39
  "lint": "eslint . --ext .js,.jsx,.ts,.tsx"
40
40
  },
41
41
  "dependencies": {
42
- "@feathersjs/adapter-commons": "5.0.0",
43
- "@feathersjs/commons": "^5.0.0",
44
- "@feathersjs/errors": "5.0.0",
45
- "@feathersjs/feathers": "5.0.0",
42
+ "@feathersjs/adapter-commons": "5.0.1",
43
+ "@feathersjs/commons": "^5.0.1",
44
+ "@feathersjs/errors": "5.0.1",
45
+ "@feathersjs/feathers": "5.0.1",
46
46
  "fast-equals": "^5.0.1",
47
- "feathers-hooks-common": "^7.0.0",
47
+ "feathers-hooks-common": "^7.0.1",
48
48
  "lodash": "^4.17.21"
49
49
  },
50
50
  "devDependencies": {
51
- "@feathersjs/memory": "^5.0.0",
51
+ "@feathersjs/memory": "^5.0.1",
52
52
  "@istanbuljs/nyc-config-typescript": "^1.0.2",
53
53
  "@types/lodash": "^4.14.191",
54
54
  "@types/mocha": "^10.0.1",
55
- "@types/node": "^18.14.1",
56
- "@typescript-eslint/eslint-plugin": "^5.53.0",
57
- "@typescript-eslint/parser": "^5.53.0",
58
- "@vitest/coverage-c8": "^0.29.1",
55
+ "@types/node": "^18.15.9",
56
+ "@typescript-eslint/eslint-plugin": "^5.56.0",
57
+ "@typescript-eslint/parser": "^5.56.0",
58
+ "@vitest/coverage-c8": "^0.29.7",
59
59
  "cross-env": "^7.0.3",
60
- "eslint": "^8.34.0",
61
- "eslint-config-prettier": "^8.6.0",
60
+ "eslint": "^8.36.0",
61
+ "eslint-config-prettier": "^8.8.0",
62
62
  "eslint-import-resolver-typescript": "^3.5.3",
63
63
  "eslint-plugin-import": "^2.27.5",
64
64
  "eslint-plugin-prettier": "^4.2.1",
65
65
  "eslint-plugin-security": "^1.7.1",
66
- "np": "^7.6.3",
66
+ "np": "^7.6.4",
67
67
  "nyc": "^15.1.0",
68
- "prettier": "^2.8.4",
68
+ "prettier": "^2.8.7",
69
69
  "shx": "^0.3.4",
70
- "typescript": "^4.9.5",
70
+ "typescript": "^5.0.2",
71
71
  "unbuild": "^1.1.2",
72
- "vitest": "^0.29.1"
72
+ "vitest": "^0.29.7"
73
73
  }
74
74
  }
@@ -8,7 +8,7 @@ export function mergeArrays<T>(
8
8
  prependKey?: Path,
9
9
  actionOnEmptyIntersect?: ActionOnEmptyIntersect
10
10
  ): T[] | undefined {
11
- if (!sourceArr || !targetArr) {
11
+ if (!sourceArr && !targetArr) {
12
12
  return;
13
13
  }
14
14
  if (handle === "target") {
@@ -25,10 +25,10 @@ export function mergeArrays<T>(
25
25
  const arr = targetArr.concat(sourceArr);
26
26
  return [...new Set(arr)];
27
27
  } else if (handle === "intersect" || handle === "intersectOrFull") {
28
- const targetIsArray = !targetArr || !Array.isArray(targetArr);
29
- const sourceIsArray = !sourceArr || !Array.isArray(sourceArr);
28
+ const targetIsNotArray = !targetArr || !Array.isArray(targetArr);
29
+ const sourceIsNotArray = !sourceArr || !Array.isArray(sourceArr);
30
30
 
31
- if ((targetIsArray || sourceIsArray) && handle === "intersect") {
31
+ if ((targetIsNotArray || sourceIsNotArray) && handle === "intersect") {
32
32
  if (actionOnEmptyIntersect) {
33
33
  actionOnEmptyIntersect(
34
34
  targetArr as unknown,
@@ -39,12 +39,12 @@ export function mergeArrays<T>(
39
39
  return;
40
40
  }
41
41
 
42
- if (handle === "intersectOrFull") {
43
- const val = !targetIsArray ? targetArr : sourceArr;
42
+ if (targetIsNotArray || sourceIsNotArray) {
43
+ const val = !targetIsNotArray ? targetArr : sourceArr;
44
44
  return val;
45
45
  }
46
46
 
47
- return targetArr.filter((val) => sourceArr.includes(val));
47
+ return targetArr!.filter((val) => sourceArr!.includes(val));
48
48
  }
49
49
  return undefined;
50
50
  }
@@ -12,13 +12,10 @@ export type ShouldSkipOptions = {
12
12
  /**
13
13
  * util to detect if a hook should be skipped
14
14
  */
15
- export const shouldSkip = <
16
- H extends HookContext = HookContext,
17
- O extends ShouldSkipOptions = ShouldSkipOptions
18
- >(
15
+ export const shouldSkip = <H extends HookContext = HookContext>(
19
16
  hookName: string,
20
17
  context: H,
21
- options?: O
18
+ options?: ShouldSkipOptions
22
19
  ): boolean => {
23
20
  if (!context.params || !context.params.skipHooks || options?.notSkippable) {
24
21
  return false;