@cabloy/utils 1.0.1 → 1.0.2

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/check.d.ts CHANGED
@@ -13,4 +13,5 @@ export declare const isEmpty: (array: any) => boolean;
13
13
  export declare const isSymbol: (val: any) => val is symbol;
14
14
  export declare function isPromise(obj: any): obj is Promise<any>;
15
15
  export declare function isNilOrEmptyString(str?: string | undefined | null): str is null | undefined | '';
16
+ export declare function checkMeta(meta?: {}, data?: {}): boolean;
16
17
  //# sourceMappingURL=check.d.ts.map
package/dist/check.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isNilOrEmptyString = exports.isPromise = exports.isSymbol = exports.isEmpty = exports.isNil = exports.isConstructor = exports.isNumber = exports.isString = exports.isFunction = exports.stripEndSlash = exports.normalizePath = exports.addLeadingSlash = exports.isPlainObject = exports.isObject = exports.isUndefined = void 0;
3
+ exports.checkMeta = exports.isNilOrEmptyString = exports.isPromise = exports.isSymbol = exports.isEmpty = exports.isNil = exports.isConstructor = exports.isNumber = exports.isString = exports.isFunction = exports.stripEndSlash = exports.normalizePath = exports.addLeadingSlash = exports.isPlainObject = exports.isObject = exports.isUndefined = void 0;
4
4
  /* eslint-disable @typescript-eslint/no-use-before-define */
5
5
  const isUndefined = (obj) => typeof obj === 'undefined';
6
6
  exports.isUndefined = isUndefined;
@@ -52,4 +52,22 @@ function isNilOrEmptyString(str) {
52
52
  return str === undefined || str === null || str === '';
53
53
  }
54
54
  exports.isNilOrEmptyString = isNilOrEmptyString;
55
+ function checkMeta(meta, data) {
56
+ // check none
57
+ if (!meta)
58
+ return true;
59
+ // loop
60
+ for (const key in meta) {
61
+ const metaItem = meta[key];
62
+ if ((0, exports.isNil)(metaItem))
63
+ continue;
64
+ if (!Array.isArray(metaItem) && metaItem !== data?.[key])
65
+ return false;
66
+ if (Array.isArray(metaItem) && !metaItem.includes(data?.[key]))
67
+ return false;
68
+ }
69
+ // default
70
+ return true;
71
+ }
72
+ exports.checkMeta = checkMeta;
55
73
  //# sourceMappingURL=check.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cabloy/utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "cabloy utils",
5
5
  "publishConfig": {
6
6
  "access": "public"