nhb-toolbox 2.7.0 → 2.7.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/array/basics.d.ts +1 -1
- package/dist/array/basics.d.ts.map +1 -1
- package/dist/array/basics.js +4 -4
- package/dist/form/convert.js +1 -1
- package/dist/form/transform.d.ts.map +1 -1
- package/dist/form/transform.js +32 -28
- package/dist/form/types.d.ts +53 -9
- package/dist/form/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -4
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
package/dist/array/basics.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const filterArrayOfObjects: <T extends GenericObject>(array: T[],
|
|
|
25
25
|
* @param value - The value to check.
|
|
26
26
|
* @returns `true` if the value is not an array, an empty array, or an array containing only `null`, `undefined`, empty objects, or empty arrays.
|
|
27
27
|
*/
|
|
28
|
-
export declare const
|
|
28
|
+
export declare const isInvalidOrEmptyArray: <T>(value: T) => boolean;
|
|
29
29
|
/**
|
|
30
30
|
* * Shuffle the elements of an array.
|
|
31
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/array/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAG,SAAS,CAAC,CAAC,CAAC,EAO5D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,aAAa,SACpD,CAAC,EAAE,cACE,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,OAAO,GAAE,KACnE,CAAC,EAeH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/array/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,KAAG,SAAS,CAAC,CAAC,CAAC,EAO5D,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,aAAa,SACpD,CAAC,EAAE,cACE,GAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,OAAO,GAAE,KACnE,CAAC,EAeH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,CAAC,KAAG,OAWnD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,CAAC,EAAE,KAAG,CAAC,EAW7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,CAAC,EAAE,KAAG,CAAC,GAAG,SAEvD,CAAC"}
|
package/dist/array/basics.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLastArrayElement = exports.shuffleArray = exports.
|
|
3
|
+
exports.getLastArrayElement = exports.shuffleArray = exports.isInvalidOrEmptyArray = exports.filterArrayOfObjects = exports.flattenArray = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* * Flattens a nested array recursively or wraps any non-array data type in an array.
|
|
6
6
|
*
|
|
@@ -45,7 +45,7 @@ exports.filterArrayOfObjects = filterArrayOfObjects;
|
|
|
45
45
|
* @param value - The value to check.
|
|
46
46
|
* @returns `true` if the value is not an array, an empty array, or an array containing only `null`, `undefined`, empty objects, or empty arrays.
|
|
47
47
|
*/
|
|
48
|
-
const
|
|
48
|
+
const isInvalidOrEmptyArray = (value) => {
|
|
49
49
|
if (!Array.isArray(value))
|
|
50
50
|
return true;
|
|
51
51
|
if (value.length === 0)
|
|
@@ -54,7 +54,7 @@ const isValidEmptyArray = (value) => {
|
|
|
54
54
|
(Array.isArray(item) && item.length === 0) || // Empty array
|
|
55
55
|
(typeof item === 'object' && Object.keys(item || {}).length === 0));
|
|
56
56
|
};
|
|
57
|
-
exports.
|
|
57
|
+
exports.isInvalidOrEmptyArray = isInvalidOrEmptyArray;
|
|
58
58
|
/**
|
|
59
59
|
* * Shuffle the elements of an array.
|
|
60
60
|
*
|
|
@@ -62,7 +62,7 @@ exports.isValidEmptyArray = isValidEmptyArray;
|
|
|
62
62
|
* @returns Shuffled array.
|
|
63
63
|
*/
|
|
64
64
|
const shuffleArray = (array) => {
|
|
65
|
-
if ((0, exports.
|
|
65
|
+
if ((0, exports.isInvalidOrEmptyArray)(array))
|
|
66
66
|
return array;
|
|
67
67
|
const shuffled = structuredClone(array);
|
|
68
68
|
for (let i = shuffled.length - 1; i > 0; i--) {
|
package/dist/form/convert.js
CHANGED
|
@@ -11,7 +11,7 @@ const basics_1 = require("../array/basics");
|
|
|
11
11
|
const convertIntoFormData = (data) => {
|
|
12
12
|
const formData = new FormData();
|
|
13
13
|
Object.entries(data).forEach(([key, value]) => {
|
|
14
|
-
if (!(0, basics_1.
|
|
14
|
+
if (!(0, basics_1.isInvalidOrEmptyArray)(value) && value[0]?.originFileObj) {
|
|
15
15
|
formData.append(key, value[0].originFileObj);
|
|
16
16
|
}
|
|
17
17
|
else if (value !== undefined && value !== null && value !== '') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/form/transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,QACzD,CAAC,YACG,eAAe,CAAC,CAAC,CAAC,KAC1B,
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/form/transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,aAAa,QACzD,CAAC,YACG,eAAe,CAAC,CAAC,CAAC,KAC1B,QAwIF,CAAC"}
|
package/dist/form/transform.js
CHANGED
|
@@ -15,28 +15,26 @@ const guards_1 = require("./guards");
|
|
|
15
15
|
const createControlledFormData = (data, configs) => {
|
|
16
16
|
const formData = new FormData();
|
|
17
17
|
const { stringifyNested = '*' } = configs || {};
|
|
18
|
-
/** Helper function to check if a key matches a dotNotation path to preserve. */
|
|
19
|
-
const shouldDotNotate = (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return configs?.dotNotateNested === '*';
|
|
18
|
+
/** - Helper function to check if a key matches a dotNotation path to preserve. */
|
|
19
|
+
const shouldDotNotate = (key) => {
|
|
20
|
+
return Array.isArray(configs?.dotNotateNested) ?
|
|
21
|
+
configs.dotNotateNested.some((path) => key === path || key.startsWith(`${path}.`))
|
|
22
|
+
: configs?.dotNotateNested === '*';
|
|
24
23
|
};
|
|
25
24
|
/** - Helper function to check if a key matches a stringifyNested key. */
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return stringifyNested === '*';
|
|
25
|
+
const shouldStringify = (key) => {
|
|
26
|
+
return Array.isArray(stringifyNested) ?
|
|
27
|
+
stringifyNested.some((path) => key === path || key.startsWith(`${path}.`))
|
|
28
|
+
: stringifyNested === '*';
|
|
31
29
|
};
|
|
32
30
|
/** - Helper function to check if a key matches a breakArray key. */
|
|
33
|
-
const shouldBreakArray = (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return configs?.breakArray === '*';
|
|
31
|
+
const shouldBreakArray = (key) => {
|
|
32
|
+
return Array.isArray(configs?.breakArray) ?
|
|
33
|
+
configs.breakArray.some((path) => key === path || key.startsWith(`${path}.`))
|
|
34
|
+
: configs?.breakArray === '*';
|
|
38
35
|
};
|
|
39
|
-
|
|
36
|
+
/** * Helper function to add values to formData */
|
|
37
|
+
const _addToFormData = (key, value) => {
|
|
40
38
|
const transformedKey = (configs?.lowerCaseKeys === '*' ||
|
|
41
39
|
configs?.lowerCaseKeys?.includes(key)) ?
|
|
42
40
|
key.toLowerCase()
|
|
@@ -52,10 +50,13 @@ const createControlledFormData = (data, configs) => {
|
|
|
52
50
|
formData.append(transformedKey, value.fileList[0].originFileObj);
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
else if (
|
|
53
|
+
else if (value instanceof Blob || value instanceof File) {
|
|
54
|
+
formData.append(transformedKey, value);
|
|
55
|
+
}
|
|
56
|
+
else if (Array.isArray(value) && !(0, basics_1.isInvalidOrEmptyArray)(value)) {
|
|
56
57
|
if (shouldBreakArray(key)) {
|
|
57
58
|
value.forEach((item, index) => {
|
|
58
|
-
|
|
59
|
+
_addToFormData(`${transformedKey}[${index}]`, item);
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
else {
|
|
@@ -65,12 +66,12 @@ const createControlledFormData = (data, configs) => {
|
|
|
65
66
|
else if (typeof value === 'object' &&
|
|
66
67
|
value !== null &&
|
|
67
68
|
!(0, basics_2.isEmptyObject)(value)) {
|
|
68
|
-
if (
|
|
69
|
+
if (shouldStringify(key) && !shouldDotNotate(key)) {
|
|
69
70
|
formData.append(transformedKey, JSON.stringify(value));
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
72
73
|
Object.entries(value).forEach(([nestedKey, nestedValue]) => {
|
|
73
|
-
|
|
74
|
+
_addToFormData(`${key}.${nestedKey}`, nestedValue);
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -79,11 +80,14 @@ const createControlledFormData = (data, configs) => {
|
|
|
79
80
|
configs?.requiredKeys?.includes(key);
|
|
80
81
|
const isNotNullish = value != null && value !== '';
|
|
81
82
|
if (isNotNullish || isRequired) {
|
|
82
|
-
formData.append(transformedKey, value
|
|
83
|
+
formData.append(transformedKey, typeof value === 'boolean' ?
|
|
84
|
+
String(value)
|
|
85
|
+
: String(value ?? ''));
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
};
|
|
86
|
-
|
|
89
|
+
/** - Helper to process object */
|
|
90
|
+
const _processObject = (obj, parentKey = '') => {
|
|
87
91
|
Object.entries(obj).forEach(([key, value]) => {
|
|
88
92
|
const fullKey = (parentKey ?
|
|
89
93
|
`${parentKey}.${key}`
|
|
@@ -97,23 +101,23 @@ const createControlledFormData = (data, configs) => {
|
|
|
97
101
|
}
|
|
98
102
|
// Check if this key is preserved
|
|
99
103
|
if (shouldDotNotate(fullKey)) {
|
|
100
|
-
// If it's a preserved path,
|
|
101
|
-
|
|
104
|
+
// If it's a preserved path, append the value directly
|
|
105
|
+
_addToFormData(fullKey, value);
|
|
102
106
|
}
|
|
103
107
|
else if (typeof value === 'object' &&
|
|
104
108
|
!Array.isArray(value) &&
|
|
105
109
|
value != null &&
|
|
106
110
|
!stringifyNested) {
|
|
107
111
|
// Process nested objects
|
|
108
|
-
|
|
112
|
+
_processObject(value, key);
|
|
109
113
|
}
|
|
110
114
|
else {
|
|
111
115
|
// For other cases, just append as key-value
|
|
112
|
-
|
|
116
|
+
_addToFormData(key, value);
|
|
113
117
|
}
|
|
114
118
|
});
|
|
115
119
|
};
|
|
116
|
-
|
|
120
|
+
_processObject(data);
|
|
117
121
|
return formData;
|
|
118
122
|
};
|
|
119
123
|
exports.createControlledFormData = createControlledFormData;
|
package/dist/form/types.d.ts
CHANGED
|
@@ -1,46 +1,90 @@
|
|
|
1
1
|
import type { DotNotationKey } from '../object/types';
|
|
2
|
-
/** - Configuration options to control
|
|
2
|
+
/** - Configuration options to control FormData generation behavior. */
|
|
3
3
|
export interface FormDataConfigs<T> {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* * An array of dot-notation keys to exclude from processing.
|
|
6
|
+
* * Ignored keys are omitted entirely, even if included in other options.
|
|
7
|
+
*/
|
|
5
8
|
ignoreKeys?: DotNotationKey<T>[];
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* * Specifies which keys should be included even if their values are falsy.
|
|
11
|
+
* * Use `*` to preserve all keys.
|
|
12
|
+
*/
|
|
7
13
|
requiredKeys?: '*' | DotNotationKey<T>[];
|
|
8
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* * Defines which keys should be converted to lowercase.
|
|
16
|
+
* * Use `*` to apply to all keys.
|
|
17
|
+
*/
|
|
9
18
|
lowerCaseKeys?: '*' | DotNotationKey<T>[];
|
|
10
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* * An array of dot-notation paths to preserve in their original structure.
|
|
21
|
+
* - Example: `'user.settings'` ensures `user` remains an object, and `settings` is not flattened.
|
|
22
|
+
* - Use `*` to preserve all keys in their dot-notation format.
|
|
23
|
+
* - If a key exists in both `dotNotateNested` and `stringifyNested`, `dotNotateNested` takes precedence.
|
|
24
|
+
*/
|
|
11
25
|
dotNotateNested?: '*' | DotNotationKey<T>[];
|
|
12
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* * Specifies which nested objects should be stringified instead of being flattened or dot-notated.
|
|
28
|
+
* - Defaults to `*`, meaning all nested objects will be stringified. Which is standard in modern form submissions.
|
|
29
|
+
* - Use `*` to stringify all nested objects.
|
|
30
|
+
* - If a key exists in both `dotNotateNested` and `stringifyNested`, `dotNotateNested` takes precedence.
|
|
31
|
+
*/
|
|
13
32
|
stringifyNested?: '*' | DotNotationKey<T>[];
|
|
14
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* * Controls how arrays should be serialized in FormData.
|
|
35
|
+
* - If a key is included, the array will be broken into individual key-value pairs (`key[0]: value, key[1]: value`).
|
|
36
|
+
* - Use `*` to apply this behavior to all array keys.
|
|
37
|
+
*/
|
|
15
38
|
breakArray?: '*' | DotNotationKey<T>[];
|
|
16
|
-
/** -
|
|
39
|
+
/** - Enables automatic trimming of string values before appending them to FormData. */
|
|
17
40
|
trimStrings?: boolean;
|
|
18
41
|
}
|
|
19
|
-
/**
|
|
42
|
+
/** * Represents a file upload operation, commonly used in libraries like `FilePond` or `Ant Design Upload`. */
|
|
20
43
|
export interface FileUpload {
|
|
44
|
+
/** The primary file being uploaded. */
|
|
21
45
|
file: CustomFile;
|
|
46
|
+
/** The list of files associated with the upload. */
|
|
22
47
|
fileList: CustomFile[];
|
|
23
48
|
}
|
|
49
|
+
/** * Represents a custom file structure used in file upload components. */
|
|
24
50
|
export interface CustomFile {
|
|
51
|
+
/** Unique identifier for the file. */
|
|
25
52
|
uid: string;
|
|
53
|
+
/** The timestamp (milliseconds) when the file was last modified. */
|
|
26
54
|
lastModified: number;
|
|
55
|
+
/** A string representation of the last modified date. */
|
|
27
56
|
lastModifiedDate: string;
|
|
57
|
+
/** The name of the file. */
|
|
28
58
|
name: string;
|
|
59
|
+
/** The size of the file in bytes. */
|
|
29
60
|
size: number;
|
|
61
|
+
/** The MIME type of the file. */
|
|
30
62
|
type: string;
|
|
63
|
+
/** Upload progress percentage (0-100). */
|
|
31
64
|
percent: number;
|
|
65
|
+
/** The original file object before any transformations. */
|
|
32
66
|
originFileObj: OriginFileObj;
|
|
67
|
+
/** The URL for a thumbnail preview of the file. */
|
|
33
68
|
thumbUrl: string;
|
|
69
|
+
/** Optional error information if the upload fails. */
|
|
34
70
|
error?: FileError;
|
|
71
|
+
/** Optional server response after a successful upload. */
|
|
35
72
|
response?: string;
|
|
73
|
+
/** Optional status of the file upload (e.g., "uploading", "done", "error"). */
|
|
36
74
|
status?: string;
|
|
37
75
|
}
|
|
76
|
+
/** * Represents the original file object before any modifications. */
|
|
38
77
|
export interface OriginFileObj {
|
|
78
|
+
/** Unique identifier for the original file. */
|
|
39
79
|
uid: string;
|
|
40
80
|
}
|
|
81
|
+
/** * Represents an error that occurs during a file upload. */
|
|
41
82
|
export interface FileError {
|
|
83
|
+
/** HTTP status code of the error. */
|
|
42
84
|
status: number;
|
|
85
|
+
/** The HTTP method used for the request (e.g., "POST", "PUT"). */
|
|
43
86
|
method: string;
|
|
87
|
+
/** The URL where the upload was attempted. */
|
|
44
88
|
url: string;
|
|
45
89
|
}
|
|
46
90
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/form/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/form/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/form/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,uEAAuE;AACvE,MAAM,WAAW,eAAe,CAAC,CAAC;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAEjC;;;OAGG;IACH,YAAY,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IAEzC;;;OAGG;IACH,aAAa,CAAC,EAAE,GAAG,GAAG,cAAc,CAAC,CAAC,CAAC,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,MAAM,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,GAAG,EAAE,MAAM,CAAC;CACZ"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { getColorForInitial } from './colors/initials';
|
|
|
9
9
|
export { generateRandomColorInHexRGB, generateRandomHSLColor, } from './colors/random';
|
|
10
10
|
export { convertColorCode, convertHex8ToHsla, convertHex8ToRgba, convertHexToHsl, convertHexToRgb, convertHslaToHex8, convertHslaToRgba, convertHslToHex, convertHslToRgb, convertRgbaToHex8, convertRgbaToHsla, convertRgbToHex, convertRgbToHsl, convertRgbToRgba, } from './colors/convert';
|
|
11
11
|
export { Color } from './colors/Color';
|
|
12
|
-
export { filterArrayOfObjects, flattenArray, isValidEmptyArray, shuffleArray,
|
|
12
|
+
export { filterArrayOfObjects, flattenArray, getLastArrayElement, isInvalidOrEmptyArray, isInvalidOrEmptyArray as isValidEmptyArray, shuffleArray, } from './array/basics';
|
|
13
13
|
export { sortAnArray } from './array/sort';
|
|
14
14
|
export { createOptionsArray, removeDuplicatesFromArray, } from './array/transform';
|
|
15
15
|
export { convertIntoFormData, isEmptyFormData } from './form/convert';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACN,gBAAgB,EAChB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGzE,OAAO,EACN,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,YAAY,IAAI,YAAY,EAC5B,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,UAAU,EACV,KAA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"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.isObject = exports.isEmptyObject = exports.generateQueryParams = exports.countObjectFields = void 0;
|
|
3
|
+
exports.createControlledFormData = exports.isEmptyFormData = exports.convertIntoFormData = exports.removeDuplicatesFromArray = exports.createOptionsArray = exports.sortAnArray = exports.shuffleArray = exports.isValidEmptyArray = exports.isInvalidOrEmptyArray = exports.getLastArrayElement = exports.flattenArray = exports.filterArrayOfObjects = exports.Color = exports.convertRgbToRgba = exports.convertRgbToHsl = exports.convertRgbToHex = exports.convertRgbaToHsla = exports.convertRgbaToHex8 = exports.convertHslToRgb = exports.convertHslToHex = exports.convertHslaToRgba = exports.convertHslaToHex8 = exports.convertHexToRgb = exports.convertHexToHsl = exports.convertHex8ToRgba = exports.convertHex8ToHsla = exports.convertColorCode = exports.generateRandomHSLColor = exports.generateRandomColorInHexRGB = exports.getColorForInitial = exports.getNumbersInRange = exports.isPrime = exports.findPrimeNumbers = exports.numberToWords = exports.isOdd = exports.isMultiple = exports.isEven = exports.getRandomNumber = exports.convertToDecimal = exports.calculateLCM = exports.calculateLCD = exports.calculateHCF = exports.calculateGCD = exports.replaceAllInString = exports.convertStringCase = exports.generateAnagrams = exports.truncateString = exports.trimString = exports.generateRandomID = exports.capitalizeString = void 0;
|
|
4
|
+
exports.throttleAction = exports.isDeepEqual = exports.debounceAction = exports.convertArrayToString = exports.convertObjectValues = exports.sanitizeData = exports.mergeObjects = exports.mergeAndFlattenObjects = exports.flattenObjectKeyValue = exports.flattenObjectDotNotation = exports.extractUpdatedFields = exports.extractUpdatedAndNewFields = exports.extractNewFields = exports.isObject = exports.isEmptyObject = exports.generateQueryParams = exports.countObjectFields = exports.cloneObject = void 0;
|
|
5
5
|
// ! String Utilities
|
|
6
6
|
var basics_1 = require("./string/basics");
|
|
7
7
|
Object.defineProperty(exports, "capitalizeString", { enumerable: true, get: function () { return basics_1.capitalizeString; } });
|
|
@@ -58,9 +58,10 @@ Object.defineProperty(exports, "Color", { enumerable: true, get: function () { r
|
|
|
58
58
|
var basics_3 = require("./array/basics");
|
|
59
59
|
Object.defineProperty(exports, "filterArrayOfObjects", { enumerable: true, get: function () { return basics_3.filterArrayOfObjects; } });
|
|
60
60
|
Object.defineProperty(exports, "flattenArray", { enumerable: true, get: function () { return basics_3.flattenArray; } });
|
|
61
|
-
Object.defineProperty(exports, "isValidEmptyArray", { enumerable: true, get: function () { return basics_3.isValidEmptyArray; } });
|
|
62
|
-
Object.defineProperty(exports, "shuffleArray", { enumerable: true, get: function () { return basics_3.shuffleArray; } });
|
|
63
61
|
Object.defineProperty(exports, "getLastArrayElement", { enumerable: true, get: function () { return basics_3.getLastArrayElement; } });
|
|
62
|
+
Object.defineProperty(exports, "isInvalidOrEmptyArray", { enumerable: true, get: function () { return basics_3.isInvalidOrEmptyArray; } });
|
|
63
|
+
Object.defineProperty(exports, "isValidEmptyArray", { enumerable: true, get: function () { return basics_3.isInvalidOrEmptyArray; } });
|
|
64
|
+
Object.defineProperty(exports, "shuffleArray", { enumerable: true, get: function () { return basics_3.shuffleArray; } });
|
|
64
65
|
var sort_1 = require("./array/sort");
|
|
65
66
|
Object.defineProperty(exports, "sortAnArray", { enumerable: true, get: function () { return sort_1.sortAnArray; } });
|
|
66
67
|
var transform_1 = require("./array/transform");
|
package/dist/utils/index.js
CHANGED
|
@@ -44,7 +44,7 @@ exports.isDeepEqual = isDeepEqual;
|
|
|
44
44
|
* @returns Converted array in string format with the separator.
|
|
45
45
|
*/
|
|
46
46
|
const convertArrayToString = (array, separator = ',') => {
|
|
47
|
-
if (!basics_1.
|
|
47
|
+
if (!basics_1.isInvalidOrEmptyArray) {
|
|
48
48
|
throw new Error('Please, provide a valid array!');
|
|
49
49
|
}
|
|
50
50
|
return array.join(separator);
|
package/package.json
CHANGED