nhb-toolbox 1.1.3 → 1.1.4
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.
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
import type { GenericObject, SanitizeOptions } from './types';
|
|
2
2
|
/**
|
|
3
|
-
* *
|
|
3
|
+
* * Sanitizes an object by ignoring specified keys and trimming string values based on options provided.
|
|
4
4
|
* * Also excludes nullish values (null, undefined) if specified. Always ignores empty nested object(s).
|
|
5
5
|
*
|
|
6
|
-
* @param object - The object to
|
|
6
|
+
* @param object - The object to sanitize.
|
|
7
7
|
* @param options - Options that define which keys to ignore, whether to trim string values, and whether to exclude nullish values.
|
|
8
8
|
* @returns A new object with the specified modifications.
|
|
9
9
|
*/
|
|
10
|
-
export declare function sanitizeData<T extends GenericObject>(object: T, options?: SanitizeOptions<T>):
|
|
10
|
+
export declare function sanitizeData<T extends GenericObject>(object: T, options?: SanitizeOptions<T>): GenericObject;
|
|
11
11
|
/**
|
|
12
|
-
* *
|
|
12
|
+
* * Sanitizes an array of objects by ignoring specified keys and trimming string values based on options provided.
|
|
13
13
|
* * Also excludes nullish values (null, undefined) if specified. Always ignores empty nested object(s).
|
|
14
14
|
*
|
|
15
|
-
* @param object - The object to
|
|
15
|
+
* @param object - The object to sanitize.
|
|
16
16
|
* @param options - Options that define which keys to ignore, whether to trim string values, and whether to exclude nullish values.
|
|
17
17
|
* @returns A new array of objects with the specified modifications.
|
|
18
18
|
*/
|
|
19
|
-
export declare function sanitizeData<T extends GenericObject>(array: T[], options?: SanitizeOptions<T>):
|
|
19
|
+
export declare function sanitizeData<T extends GenericObject>(array: T[], options?: SanitizeOptions<T>): GenericObject[];
|
|
20
20
|
/**
|
|
21
|
-
* * Trims all the words in a string
|
|
21
|
+
* * Trims all the words in a string.
|
|
22
22
|
*
|
|
23
|
-
* @param input String
|
|
24
|
-
* @returns
|
|
23
|
+
* @param input String to sanitize.
|
|
24
|
+
* @returns Sanitized string .
|
|
25
25
|
*/
|
|
26
|
-
export declare function sanitizeData(input: string
|
|
26
|
+
export declare function sanitizeData(input: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* * Trims all the words in an array of strings.
|
|
29
|
+
*
|
|
30
|
+
* @param input Array of strings to sanitize.
|
|
31
|
+
* @returns Sanitized array of strings.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sanitizeData(input: string[]): string[];
|
|
27
34
|
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/object/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,aAAa,EACnD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/object/sanitize.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAkB,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE9E;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,aAAa,EACnD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,aAAa,CAAC;AAEjB;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,aAAa,EACnD,KAAK,EAAE,CAAC,EAAE,EACV,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,aAAa,EAAE,CAAC;AAEnB;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC"}
|
package/dist/object/sanitize.js
CHANGED
|
@@ -4,15 +4,15 @@ exports.sanitizeData = sanitizeData;
|
|
|
4
4
|
const index_1 = require("./index");
|
|
5
5
|
const string_1 = require("../string");
|
|
6
6
|
/**
|
|
7
|
-
* *
|
|
7
|
+
* * Sanitizes a string, array of strings, an object or array of objects by ignoring specified keys and trimming string values.
|
|
8
8
|
* * Also excludes nullish values (null, undefined) if specified. Always ignores empty nested object(s).
|
|
9
9
|
*
|
|
10
|
-
* @param input - The object or array of objects to
|
|
10
|
+
* @param input - The string, object or array of strings or objects to sanitize.
|
|
11
11
|
* @param options - Options for processing.
|
|
12
|
-
* @returns A new string, array of strings
|
|
12
|
+
* @returns A new string, object or array of strings or objects with the specified modifications.
|
|
13
13
|
*/
|
|
14
14
|
function sanitizeData(input, options) {
|
|
15
|
-
const { ignoreKeys = [], trimStrings = true, ignoreNullish = false, } = options || {};
|
|
15
|
+
const { keysToIgnore: ignoreKeys = [], trimStrings = true, ignoreNullish = false, } = options || {};
|
|
16
16
|
// Flatten the object keys and use the keys for comparison
|
|
17
17
|
const ignoreKeySet = new Set(ignoreKeys);
|
|
18
18
|
/**
|
package/dist/object/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type DotNotationKey<T> = T extends object ? {
|
|
|
7
7
|
/** - Options for `sanitizeData` */
|
|
8
8
|
export interface SanitizeOptions<T extends GenericObject> {
|
|
9
9
|
/** Keys to ignore */
|
|
10
|
-
|
|
10
|
+
keysToIgnore?: DotNotationKey<T>[];
|
|
11
11
|
/** Whether to trim string values. Defaults to `true` */
|
|
12
12
|
trimStrings?: boolean;
|
|
13
13
|
/** Whether to exclude nullish (null or undefined) values. Defaults to `false` */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/object/types.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM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