@vroskus/library-helpers 1.0.20 → 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,9 +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
- return lodash_1.default.mapValues(withoutHiddenItemsData, (value) => (value === '' || isEmptyString(value) ? null : value));
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
+ });
35
48
  };
36
49
  exports.cleanFormValues = cleanFormValues;
37
50
  const animationClass = (name) => {
package/dist/common.d.ts CHANGED
@@ -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.20",
3
+ "version": "1.0.22",
4
4
  "description": "Utility helpers",
5
5
  "author": "Vilius Roškus <info@regattas.eu>",
6
6
  "license": "MIT",