@vroskus/library-helpers 1.0.19 → 1.0.22

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/browser.js CHANGED
@@ -29,10 +29,22 @@ const isEmptyString = (value) => {
29
29
  }
30
30
  return false;
31
31
  };
32
+ const isObject = (input) => input !== null
33
+ && typeof input === 'object'
34
+ && (input === null || input === void 0 ? void 0 : input.constructor) === Object;
32
35
  const cleanFormValues = (data) => {
33
36
  const withoutHiddenItemsData = lodash_1.default.omitBy(data, (value, key) => lodash_1.default.startsWith(key, '_'));
34
- const cleanData = lodash_1.default.mapValues(withoutHiddenItemsData, (value) => (value === '' || isEmptyString(value) ? null : value));
35
- return cleanData;
37
+ return lodash_1.default.mapValues(withoutHiddenItemsData, (value) => {
38
+ if (Array.isArray(value) === true) {
39
+ return value.map((valueValue) => {
40
+ if (isObject(valueValue) === true) {
41
+ return (0, exports.cleanFormValues)(valueValue);
42
+ }
43
+ return isEmptyString(valueValue) === true ? null : valueValue;
44
+ });
45
+ }
46
+ return isEmptyString(value) === true ? null : value;
47
+ });
36
48
  };
37
49
  exports.cleanFormValues = cleanFormValues;
38
50
  const animationClass = (name) => {
package/dist/common.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { RequestHandler } from 'express';
2
- export declare const getValue: <V extends string | void | null>(value: V, defaultValue: V) => V;
2
+ export declare const getValue: <V extends null | string | void>(value: V, defaultValue: V) => V;
3
3
  export declare const durationMiddleware: () => RequestHandler;
4
4
  export declare const getDuration: (start: [number, number] | void) => number;
5
- export declare const sortData: <D extends Record<string, unknown>[]>(data: D, field: Array<string> | string, reverse?: boolean) => Promise<D>;
5
+ export declare const sortData: <D extends Array<Record<string, unknown>>>(data: D, field: Array<string> | string, reverse?: boolean) => Promise<D>;
6
6
  export declare const getImageUrl: ({ cdnUrl, image, size, undefinedImage, }: {
7
7
  cdnUrl: string;
8
8
  image?: null | string;
9
- size: 'max' | 'mid' | 'min' | 'sqr';
9
+ size: "max" | "mid" | "min" | "sqr";
10
10
  undefinedImage?: string;
11
11
  }) => string;
12
12
  export declare const getFileUrl: ({ cdnUrl, file, }: {
@@ -21,3 +21,4 @@ export declare const getObjectKeys: <T extends Record<string, unknown>, K extend
21
21
  export declare const getObjectValues: <T extends Record<string, unknown>, K extends keyof T>(o: T) => T[K][];
22
22
  export declare const getObjectEntries: <T extends Record<string, unknown>, K extends keyof T>(o: T) => [K, T[K]][];
23
23
  export declare const numberValue: (input: unknown) => number;
24
+ export declare const nullValue: (input: unknown) => null | unknown;
package/dist/common.js CHANGED
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.numberValue = exports.getObjectEntries = exports.getObjectValues = exports.getObjectKeys = exports.isDiff = exports.sleep = exports.makeRollingCode = exports.makeCode = exports.getFileUrl = exports.getImageUrl = exports.sortData = exports.getDuration = exports.durationMiddleware = exports.getValue = void 0;
15
+ exports.nullValue = exports.numberValue = exports.getObjectEntries = exports.getObjectValues = exports.getObjectKeys = exports.isDiff = exports.sleep = exports.makeRollingCode = exports.makeCode = exports.getFileUrl = exports.getImageUrl = exports.sortData = exports.getDuration = exports.durationMiddleware = exports.getValue = void 0;
16
16
  const lodash_1 = __importDefault(require("lodash"));
17
17
  const moment_1 = __importDefault(require("moment"));
18
18
  const aigle_1 = __importDefault(require("aigle"));
@@ -77,3 +77,5 @@ exports.getObjectValues = Object.values;
77
77
  exports.getObjectEntries = Object.entries;
78
78
  const numberValue = (input) => (input === '' ? 0 : Number(input));
79
79
  exports.numberValue = numberValue;
80
+ const nullValue = (input) => (input === '' ? null : input);
81
+ exports.nullValue = nullValue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vroskus/library-helpers",
3
- "version": "1.0.19",
3
+ "version": "1.0.22",
4
4
  "description": "Utility helpers",
5
5
  "author": "Vilius Roškus <info@regattas.eu>",
6
6
  "license": "MIT",
@@ -25,25 +25,16 @@
25
25
  "express": "^4.19.2",
26
26
  "lodash": "^4.17.21",
27
27
  "moment": "2.29.4",
28
- "query-string": "^9.0.0",
28
+ "query-string": "^9.1.0",
29
29
  "react-animations": "^1.0.0",
30
30
  "short-hash": "^1.0.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/jest": "^29.5.12",
34
- "@types/lodash": "^4.17.1",
35
- "@types/node": "^20.12.10",
34
+ "@types/lodash": "^4.17.7",
35
+ "@types/node": "^22.4.1",
36
36
  "@types/query-string": "^6.3.0",
37
- "@typescript-eslint/eslint-plugin": "^7.8.0",
38
- "@typescript-eslint/parser": "^7.8.0",
39
- "eslint": "^8.57.0",
40
- "eslint-config-airbnb-base": "^15.0.0",
41
- "eslint-config-airbnb-typescript": "^18.0.0",
42
- "eslint-config-problems": "^8.0.0",
43
- "eslint-plugin-import": "^2.29.1",
44
- "eslint-plugin-import-newlines": "^1.4.0",
45
- "eslint-plugin-perfectionist": "^2.10.0",
46
- "eslint-plugin-react": "^7.34.1",
37
+ "@vroskus/eslint-config": "^1.0.11",
47
38
  "typescript": "^5.4.5"
48
39
  }
49
40
  }