payload-sanitizer 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,131 @@
1
+ # payload-sanitizer
2
+
3
+ Tiny zero‑dependency sanitizer for JS/TS payloads that removes common junk (empty strings, whitespace-only strings, `null`, `undefined`, optional dash marker, `NaN`) without mutating the original value. Works in both frontend and backend code.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ # pnpm
9
+ pnpm add payload-sanitizer
10
+
11
+ # npm
12
+ npm i payload-sanitizer
13
+
14
+ # yarn
15
+ yarn add payload-sanitizer
16
+ ```
17
+
18
+ ## Quick start
19
+
20
+ ```ts
21
+ import { sanitize } from "payload-sanitizer";
22
+
23
+ const input = {
24
+ trxId: "",
25
+ status: "-",
26
+ fromDate: " 2026-02-01 ",
27
+ toDate: null,
28
+ page: 1,
29
+ includeInactive: false,
30
+ };
31
+
32
+ const clean = sanitize(input, {
33
+ drop: ["undefined", "null", "emptyString", "whitespaceString", "dash"],
34
+ });
35
+
36
+ console.log(clean);
37
+ // {
38
+ // fromDate: "2026-02-01",
39
+ // page: 1,
40
+ // includeInactive: false
41
+ // }
42
+ ```
43
+
44
+ ## Why this instead of validation libraries?
45
+
46
+ Validation libs (e.g., Zod) parse **against a schema**. `payload-sanitizer` just **cleans/normalizes** data with simple rules—no schema required. They pair well:
47
+
48
+ ```ts
49
+ const cleaned = sanitize(formValues);
50
+ const parsed = schema.parse(cleaned);
51
+ ```
52
+
53
+ ## API
54
+
55
+ ### `sanitize(payload, options?)`
56
+
57
+ Returns a cleaned clone of `payload` (objects and arrays) without mutating the input.
58
+
59
+ **Options**
60
+ - `deep` (default `true`): recurse into nested objects.
61
+ - `trimStrings` (default `true`): `value.trim()` on strings before checks.
62
+ - `cleanArrays` (default `true`): sanitize array items and drop ones that should be removed.
63
+ - `drop` (defaults to `["undefined","null","emptyString","whitespaceString"]`): presets to remove. Presets: `"undefined" | "null" | "emptyString" | "whitespaceString" | "dash" | "nan"`.
64
+ - `keepKeys`: key names to always keep even if value looks droppable.
65
+ - `dropKeys`: key names to always remove.
66
+ - `dropValues`: explicit values to remove (uses `Object.is`).
67
+ - `shouldDrop(value, keyPath)`: custom predicate; return `true` to drop. `keyPath` is an array of keys/indexes from root.
68
+
69
+ Notes:
70
+ - `0`, `false`, and `""` inside `keepKeys` are preserved by design.
71
+ - If everything is dropped, arrays become `[]`, objects become `{}`; primitives are returned as-is.
72
+
73
+ ### `sanitize.with(baseOptions)`
74
+
75
+ Creates a preconfigured sanitizer.
76
+
77
+ ```ts
78
+ const sanitizeSearch = sanitize.with({
79
+ drop: ["undefined", "null", "emptyString", "whitespaceString", "dash"],
80
+ });
81
+
82
+ sanitizeSearch({ q: " hello ", status: "-" });
83
+ // { q: "hello" }
84
+ ```
85
+
86
+ ### `createSanitizer(baseOptions)`
87
+
88
+ Factory equivalent to `sanitize.with`.
89
+
90
+ ```ts
91
+ import { createSanitizer } from "payload-sanitizer";
92
+ const sanitizePayload = createSanitizer({ deep: true });
93
+ ```
94
+
95
+ ## Common patterns
96
+
97
+ - **Frontend forms** — clean before sending:
98
+ ```ts
99
+ await api.post("/search", sanitize(values));
100
+ ```
101
+ - **Backend filters** — strip empty query params:
102
+ ```ts
103
+ const filters = sanitize(req.query, { drop: ["dash"] });
104
+ db.find(filters);
105
+ ```
106
+ - **Custom rule** — drop empty `filters` objects:
107
+ ```ts
108
+ sanitize(payload, {
109
+ shouldDrop: (value, path) =>
110
+ path.at(-1) === "filters" &&
111
+ typeof value === "object" &&
112
+ value !== null &&
113
+ Object.keys(value as any).length === 0,
114
+ });
115
+ ```
116
+ - **Drop exact values**:
117
+ ```ts
118
+ sanitize(data, { dropValues: ["N/A", Number.NaN] });
119
+ ```
120
+
121
+ ## Development
122
+
123
+ ```bash
124
+ pnpm install
125
+ pnpm test
126
+ pnpm build
127
+ ```
128
+
129
+ ## License
130
+
131
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,128 @@
1
+ 'use strict';
2
+
3
+ // src/index.ts
4
+ var DEFAULT_DROP = [
5
+ "undefined",
6
+ "null",
7
+ "emptyString",
8
+ "whitespaceString"
9
+ ];
10
+ var DEFAULT_OPTIONS = {
11
+ deep: true,
12
+ trimStrings: true,
13
+ cleanArrays: true,
14
+ drop: DEFAULT_DROP
15
+ };
16
+ function isPlainObject(value) {
17
+ if (value === null || typeof value !== "object") return false;
18
+ const proto = Object.getPrototypeOf(value);
19
+ return proto === Object.prototype || proto === null;
20
+ }
21
+ function normalizeValue(value, opts) {
22
+ if (typeof value === "string" && opts.trimStrings) {
23
+ return value.trim();
24
+ }
25
+ return value;
26
+ }
27
+ function shouldDropPreset(value, drop) {
28
+ for (const d of drop) {
29
+ switch (d) {
30
+ case "undefined":
31
+ if (value === void 0) return true;
32
+ break;
33
+ case "null":
34
+ if (value === null) return true;
35
+ break;
36
+ case "emptyString":
37
+ if (value === "") return true;
38
+ break;
39
+ case "whitespaceString":
40
+ if (typeof value === "string" && value.trim() === "") return true;
41
+ break;
42
+ case "dash":
43
+ if (value === "-") return true;
44
+ break;
45
+ case "nan":
46
+ if (typeof value === "number" && Number.isNaN(value)) return true;
47
+ break;
48
+ }
49
+ }
50
+ return false;
51
+ }
52
+ function shouldDropExact(value, exactValues) {
53
+ if (!exactValues || exactValues.length === 0) return false;
54
+ for (const v of exactValues) {
55
+ if (Object.is(value, v)) return true;
56
+ }
57
+ return false;
58
+ }
59
+ function hasKey(list, key) {
60
+ return !!list && list.includes(key);
61
+ }
62
+ function sanitizeAny(input, options, path) {
63
+ const normalized = normalizeValue(input, options);
64
+ if (shouldDropPreset(normalized, options.drop)) return void 0;
65
+ if (shouldDropExact(normalized, options.dropValues)) return void 0;
66
+ if (options.shouldDrop?.(normalized, path)) return void 0;
67
+ if (Array.isArray(normalized)) {
68
+ if (!options.cleanArrays) return normalized.slice();
69
+ const out = [];
70
+ for (let i = 0; i < normalized.length; i++) {
71
+ const next = sanitizeAny(normalized[i], options, path.concat(i));
72
+ if (next !== void 0) out.push(next);
73
+ }
74
+ return out;
75
+ }
76
+ if (isPlainObject(normalized)) {
77
+ if (!options.deep) {
78
+ const out2 = {};
79
+ for (const [k, v] of Object.entries(normalized)) {
80
+ if (hasKey(options.dropKeys, k)) continue;
81
+ if (hasKey(options.keepKeys, k)) {
82
+ out2[k] = v;
83
+ continue;
84
+ }
85
+ const next = sanitizeAny(v, options, path.concat(k));
86
+ if (next !== void 0) out2[k] = next;
87
+ }
88
+ return out2;
89
+ }
90
+ const out = {};
91
+ for (const [k, v] of Object.entries(normalized)) {
92
+ if (hasKey(options.dropKeys, k)) continue;
93
+ if (hasKey(options.keepKeys, k)) {
94
+ out[k] = v;
95
+ continue;
96
+ }
97
+ const next = sanitizeAny(v, options, path.concat(k));
98
+ if (next !== void 0) out[k] = next;
99
+ }
100
+ return out;
101
+ }
102
+ return normalized;
103
+ }
104
+ function sanitize(payload, options = {}) {
105
+ const merged = {
106
+ ...DEFAULT_OPTIONS,
107
+ ...options,
108
+ drop: options.drop ?? DEFAULT_OPTIONS.drop
109
+ };
110
+ const result = sanitizeAny(payload, merged, []);
111
+ if (result === void 0) {
112
+ if (isPlainObject(payload)) return {};
113
+ if (Array.isArray(payload)) return [];
114
+ return payload;
115
+ }
116
+ return result;
117
+ }
118
+ var createSanitizer = (baseOptions = {}) => {
119
+ return (payload, options = {}) => sanitize(payload, { ...baseOptions, ...options });
120
+ };
121
+ sanitize.with = (baseOptions = {}) => createSanitizer(baseOptions);
122
+ var sanitizeWith = sanitize.with;
123
+
124
+ exports.createSanitizer = createSanitizer;
125
+ exports.sanitize = sanitize;
126
+ exports.sanitizeWith = sanitizeWith;
127
+ //# sourceMappingURL=index.cjs.map
128
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["out"],"mappings":";;;AAqBA,IAAM,YAAA,GAA6B;AAAA,EACjC,WAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,eAAA,GAEuB;AAAA,EAC3B,IAAA,EAAM,IAAA;AAAA,EACN,WAAA,EAAa,IAAA;AAAA,EACb,WAAA,EAAa,IAAA;AAAA,EACb,IAAA,EAAM;AACR,CAAA;AAEA,SAAS,cAAc,KAAA,EAAkD;AACvE,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,UAAU,OAAO,KAAA;AACxD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA;AACzC,EAAA,OAAO,KAAA,KAAU,MAAA,CAAO,SAAA,IAAa,KAAA,KAAU,IAAA;AACjD;AAEA,SAAS,cAAA,CACP,OACA,IAAA,EACA;AACA,EAAA,IAAI,OA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AE,CAAA;AAE9C,EAAA,IAAI,WAAW,MAAA,EAAW;AACxB,IAAA,IAAI,aAAA,CAAc,OAAO,CAAA,EAAG,OAAO,EAAC;AACpC,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,SAAU,EAAC;AACpC,IAAA,OAAO,OAAA;AAAA,EACT;AAEA,EAAA,OAAO,MAAA;AACT;AAOO,IAAM,eAAA,GAAkB,CAAC,WAAA,GAA+B,EAAC,KAAM;AACpE,EAAA,OAAO,CAAI,OAAA,EAAY,OAAA,GAA2B,EAAC,KACjD,QAAA,CAAS,OAAA,EAAS,EAAE,GAAG,WAAA,EAAa,GAAG,OAAA,EAAS,CAAA;AACpD;AAEC,QAAA,CAAyB,OAAO,CAAC,WAAA,GAA+B,EAAC,KAChE,gBAAgB,WAAW,CAAA;AAEtB,IAAM,eAAgB,QAAA,CAAyB","file":"index.cjs","sourcesContent":["export type DropPreset =\n | \"null\"\n | \"undefined\"\n | \"emptyString\"\n | \"whitespaceString\"\n | \"dash\"\n | \"nan\";\n\nexport type KeyPath = Array<string | number>;\n\nexport type SanitizeOptions = {\n deep?: boolean;\n trimStrings?: boolean;\n cleanArrays?: boolean;\n drop?: DropPreset[];\n keepKeys?: string[];\n dropKeys?: string[];\n dropValues?: unknown[];\n shouldDrop?: (value: unknown, keyPath: KeyPath) => boolean;\n};\n\nconst DEFAULT_DROP: DropPreset[] = [\n \"undefined\",\n \"null\",\n \"emptyString\",\n \"whitespaceString\",\n];\n\nconst DEFAULT_OPTIONS: Required<\n Pick<SanitizeOptions, \"deep\" | \"trimStrings\" | \"cleanArrays\">\n> & { drop: DropPreset[] } = {\n deep: true,\n trimStrings: true,\n cleanArrays: true,\n drop: DEFAULT_DROP,\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\") return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\nfunction normalizeValue(\n value: unknown,\n opts: Required<typeof DEFAULT_OPTIONS>,\n) {\n if (typeof value === \"string\" && opts.trimStrings) {\n return value.trim();\n }\n return value;\n}\n\nfunction shouldDropPreset(value: unknown, drop: DropPreset[]): boolean {\n for (const d of drop) {\n switch (d) {\n case \"undefined\":\n if (value === undefined) return true;\n break;\n case \"null\":\n if (value === null) return true;\n break;\n case \"emptyString\":\n if (value === \"\") return true;\n break;\n case \"whitespaceString\":\n // only matters if trimStrings is false; but still safe:\n if (typeof value === \"string\" && value.trim() === \"\") return true;\n break;\n case \"dash\":\n if (value === \"-\") return true;\n break;\n case \"nan\":\n if (typeof value === \"number\" && Number.isNaN(value)) return true;\n break;\n }\n }\n return false;\n}\n\nfunction shouldDropExact(value: unknown, exactValues?: unknown[]): boolean {\n if (!exactValues || exactValues.length === 0) return false;\n for (const v of exactValues) {\n if (Object.is(value, v)) return true;\n }\n return false;\n}\n\nfunction hasKey(list: string[] | undefined, key: string): boolean {\n return !!list && list.includes(key);\n}\n\nfunction sanitizeAny(\n input: unknown,\n options: Required<typeof DEFAULT_OPTIONS> & SanitizeOptions,\n path: KeyPath,\n): unknown {\n const normalized = normalizeValue(input, options);\n\n if (shouldDropPreset(normalized, options.drop)) return undefined;\n if (shouldDropExact(normalized, options.dropValues)) return undefined;\n if (options.shouldDrop?.(normalized, path)) return undefined;\n\n if (Array.isArray(normalized)) {\n if (!options.cleanArrays) return normalized.slice();\n const out: unknown[] = [];\n for (let i = 0; i < normalized.length; i++) {\n const next = sanitizeAny(normalized[i], options, path.concat(i));\n if (next !== undefined) out.push(next);\n }\n return out;\n }\n\n if (isPlainObject(normalized)) {\n if (!options.deep) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(normalized)) {\n if (hasKey(options.dropKeys, k)) continue;\n if (hasKey(options.keepKeys, k)) {\n out[k] = v;\n continue;\n }\n const next = sanitizeAny(v, options, path.concat(k));\n if (next !== undefined) out[k] = next;\n }\n return out;\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(normalized)) {\n if (hasKey(options.dropKeys, k)) continue;\n\n if (hasKey(options.keepKeys, k)) {\n out[k] = v;\n continue;\n }\n\n const next = sanitizeAny(v, options, path.concat(k));\n if (next !== undefined) out[k] = next;\n }\n return out;\n }\n\n return normalized;\n}\n\nexport function sanitize<T>(payload: T, options: SanitizeOptions = {}): T {\n const merged = {\n ...DEFAULT_OPTIONS,\n ...options,\n drop: options.drop ?? DEFAULT_OPTIONS.drop,\n };\n\n const result = sanitizeAny(payload, merged, []);\n\n if (result === undefined) {\n if (isPlainObject(payload)) return {} as T;\n if (Array.isArray(payload)) return [] as T;\n return payload;\n }\n\n return result as T;\n}\n\ntype SanitizerFn = {\n <T>(payload: T, options?: SanitizeOptions): T;\n with: (baseOptions?: SanitizeOptions) => ReturnType<typeof createSanitizer>;\n};\n\nexport const createSanitizer = (baseOptions: SanitizeOptions = {}) => {\n return <T>(payload: T, options: SanitizeOptions = {}) =>\n sanitize(payload, { ...baseOptions, ...options });\n};\n\n(sanitize as SanitizerFn).with = (baseOptions: SanitizeOptions = {}) =>\n createSanitizer(baseOptions);\n\nexport const sanitizeWith = (sanitize as SanitizerFn).with;\n"]}
@@ -0,0 +1,17 @@
1
+ type DropPreset = "null" | "undefined" | "emptyString" | "whitespaceString" | "dash" | "nan";
2
+ type KeyPath = Array<string | number>;
3
+ type SanitizeOptions = {
4
+ deep?: boolean;
5
+ trimStrings?: boolean;
6
+ cleanArrays?: boolean;
7
+ drop?: DropPreset[];
8
+ keepKeys?: string[];
9
+ dropKeys?: string[];
10
+ dropValues?: unknown[];
11
+ shouldDrop?: (value: unknown, keyPath: KeyPath) => boolean;
12
+ };
13
+ declare function sanitize<T>(payload: T, options?: SanitizeOptions): T;
14
+ declare const createSanitizer: (baseOptions?: SanitizeOptions) => <T>(payload: T, options?: SanitizeOptions) => T;
15
+ declare const sanitizeWith: (baseOptions?: SanitizeOptions) => ReturnType<typeof createSanitizer>;
16
+
17
+ export { type DropPreset, type KeyPath, type SanitizeOptions, createSanitizer, sanitize, sanitizeWith };
@@ -0,0 +1,17 @@
1
+ type DropPreset = "null" | "undefined" | "emptyString" | "whitespaceString" | "dash" | "nan";
2
+ type KeyPath = Array<string | number>;
3
+ type SanitizeOptions = {
4
+ deep?: boolean;
5
+ trimStrings?: boolean;
6
+ cleanArrays?: boolean;
7
+ drop?: DropPreset[];
8
+ keepKeys?: string[];
9
+ dropKeys?: string[];
10
+ dropValues?: unknown[];
11
+ shouldDrop?: (value: unknown, keyPath: KeyPath) => boolean;
12
+ };
13
+ declare function sanitize<T>(payload: T, options?: SanitizeOptions): T;
14
+ declare const createSanitizer: (baseOptions?: SanitizeOptions) => <T>(payload: T, options?: SanitizeOptions) => T;
15
+ declare const sanitizeWith: (baseOptions?: SanitizeOptions) => ReturnType<typeof createSanitizer>;
16
+
17
+ export { type DropPreset, type KeyPath, type SanitizeOptions, createSanitizer, sanitize, sanitizeWith };
package/dist/index.js ADDED
@@ -0,0 +1,124 @@
1
+ // src/index.ts
2
+ var DEFAULT_DROP = [
3
+ "undefined",
4
+ "null",
5
+ "emptyString",
6
+ "whitespaceString"
7
+ ];
8
+ var DEFAULT_OPTIONS = {
9
+ deep: true,
10
+ trimStrings: true,
11
+ cleanArrays: true,
12
+ drop: DEFAULT_DROP
13
+ };
14
+ function isPlainObject(value) {
15
+ if (value === null || typeof value !== "object") return false;
16
+ const proto = Object.getPrototypeOf(value);
17
+ return proto === Object.prototype || proto === null;
18
+ }
19
+ function normalizeValue(value, opts) {
20
+ if (typeof value === "string" && opts.trimStrings) {
21
+ return value.trim();
22
+ }
23
+ return value;
24
+ }
25
+ function shouldDropPreset(value, drop) {
26
+ for (const d of drop) {
27
+ switch (d) {
28
+ case "undefined":
29
+ if (value === void 0) return true;
30
+ break;
31
+ case "null":
32
+ if (value === null) return true;
33
+ break;
34
+ case "emptyString":
35
+ if (value === "") return true;
36
+ break;
37
+ case "whitespaceString":
38
+ if (typeof value === "string" && value.trim() === "") return true;
39
+ break;
40
+ case "dash":
41
+ if (value === "-") return true;
42
+ break;
43
+ case "nan":
44
+ if (typeof value === "number" && Number.isNaN(value)) return true;
45
+ break;
46
+ }
47
+ }
48
+ return false;
49
+ }
50
+ function shouldDropExact(value, exactValues) {
51
+ if (!exactValues || exactValues.length === 0) return false;
52
+ for (const v of exactValues) {
53
+ if (Object.is(value, v)) return true;
54
+ }
55
+ return false;
56
+ }
57
+ function hasKey(list, key) {
58
+ return !!list && list.includes(key);
59
+ }
60
+ function sanitizeAny(input, options, path) {
61
+ const normalized = normalizeValue(input, options);
62
+ if (shouldDropPreset(normalized, options.drop)) return void 0;
63
+ if (shouldDropExact(normalized, options.dropValues)) return void 0;
64
+ if (options.shouldDrop?.(normalized, path)) return void 0;
65
+ if (Array.isArray(normalized)) {
66
+ if (!options.cleanArrays) return normalized.slice();
67
+ const out = [];
68
+ for (let i = 0; i < normalized.length; i++) {
69
+ const next = sanitizeAny(normalized[i], options, path.concat(i));
70
+ if (next !== void 0) out.push(next);
71
+ }
72
+ return out;
73
+ }
74
+ if (isPlainObject(normalized)) {
75
+ if (!options.deep) {
76
+ const out2 = {};
77
+ for (const [k, v] of Object.entries(normalized)) {
78
+ if (hasKey(options.dropKeys, k)) continue;
79
+ if (hasKey(options.keepKeys, k)) {
80
+ out2[k] = v;
81
+ continue;
82
+ }
83
+ const next = sanitizeAny(v, options, path.concat(k));
84
+ if (next !== void 0) out2[k] = next;
85
+ }
86
+ return out2;
87
+ }
88
+ const out = {};
89
+ for (const [k, v] of Object.entries(normalized)) {
90
+ if (hasKey(options.dropKeys, k)) continue;
91
+ if (hasKey(options.keepKeys, k)) {
92
+ out[k] = v;
93
+ continue;
94
+ }
95
+ const next = sanitizeAny(v, options, path.concat(k));
96
+ if (next !== void 0) out[k] = next;
97
+ }
98
+ return out;
99
+ }
100
+ return normalized;
101
+ }
102
+ function sanitize(payload, options = {}) {
103
+ const merged = {
104
+ ...DEFAULT_OPTIONS,
105
+ ...options,
106
+ drop: options.drop ?? DEFAULT_OPTIONS.drop
107
+ };
108
+ const result = sanitizeAny(payload, merged, []);
109
+ if (result === void 0) {
110
+ if (isPlainObject(payload)) return {};
111
+ if (Array.isArray(payload)) return [];
112
+ return payload;
113
+ }
114
+ return result;
115
+ }
116
+ var createSanitizer = (baseOptions = {}) => {
117
+ return (payload, options = {}) => sanitize(payload, { ...baseOptions, ...options });
118
+ };
119
+ sanitize.with = (baseOptions = {}) => createSanitizer(baseOptions);
120
+ var sanitizeWith = sanitize.with;
121
+
122
+ export { createSanitizer, sanitize, sanitizeWith };
123
+ //# sourceMappingURL=index.js.map
124
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["out"],"mappings":";AAqBA,IAAM,YAAA,GAA6B;AAAA,EACjC,WAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA;AACF,CAAA;AAEA,IAAM,eAAA,GAEuB;AAAA,EAC3B,IAAA,EAAM,IAAA;AAAA,EACN,WAAA,EAAa,IAAA;AAAA,EACb,WAAA,EAAa,IAAA;AAAA,EACb,IAAA,EAAM;AACR,CAAA;AAEA,SAAS,cAAc,KAAA,EAAkD;AACvE,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,OAAO,KAAA,KAAU,UAAU,OAAO,KAAA;AACxD,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,cAAA,CAAe,KAAK,CAAA;AACzC,EAAA,OAAO,KAAA,KAAU,MAAA,CAAO,SAAA,IAAa,KAAA,KAAU,IAAA;AACjD;AAEA,SAAS,cAAA,CACP,OACA,IAAA,EACA;AACA,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,IAAY,IAAA,CAAK,WAAA,EAAa;AACjD,IAAA,OAAO,MAAM,IAAA,EAAK;AAAA,EACpB;AACA,EAAA,OAAO,KAAA;AACT;AAEA,SAAS,gBAAA,CAAiB,OAAgB,IAAA,EAA6B;AACrE,EAAA,KAAA,MAAW,KAAK,IAAA,EAAM;AACpB,IAA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,MAAA;AACT;AAOO,IAAM,eAAA,GAAkB,CAAC,WAAA,GAA+B,EAAC,KAAM;AACpE,EAAA,OAAO,CAAI,OAAA,EAAY,OAAA,GAA2B,EAAC,KACjD,QAAA,CAAS,OAAA,EAAS,EAAE,GAAG,WAAA,EAAa,GAAG,OAAA,EAAS,CAAA;AACpD;AAEC,QAAA,CAAyB,OAAO,CAAC,WAAA,GAA+B,EAAC,KAChE,gBAAgB,WAAW,CAAA;AAEtB,IAAM,eAAgB,QAAA,CAAyB","file":"index.js","sourcesContent":["export type DropPreset =\n | \"null\"\n | \"undefined\"\n | \"emptyString\"\n | \"whitespaceString\"\n | \"dash\"\n | \"nan\";\n\nexport type KeyPath = Array<string | number>;\n\nexport type SanitizeOptions = {\n deep?: boolean;\n trimStrings?: boolean;\n cleanArrays?: boolean;\n drop?: DropPreset[];\n keepKeys?: string[];\n dropKeys?: string[];\n dropValues?: unknown[];\n shouldDrop?: (value: unknown, keyPath: KeyPath) => boolean;\n};\n\nconst DEFAULT_DROP: DropPreset[] = [\n \"undefined\",\n \"null\",\n \"emptyString\",\n \"whitespaceString\",\n];\n\nconst DEFAULT_OPTIONS: Required<\n Pick<SanitizeOptions, \"deep\" | \"trimStrings\" | \"cleanArrays\">\n> & { drop: DropPreset[] } = {\n deep: true,\n trimStrings: true,\n cleanArrays: true,\n drop: DEFAULT_DROP,\n};\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\") return false;\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\nfunction normalizeValue(\n value: unknown,\n opts: Required<typeof DEFAULT_OPTIONS>,\n) {\n if (typeof value === \"string\" && opts.trimStrings) {\n return value.trim();\n }\n return value;\n}\n\nfunction shouldDropPreset(value: unknown, drop: DropPreset[]): boolean {\n for (const d of drop) {\n switch (d) {\n case \"undefined\":\n if (value === undefined) return true;\n break;\n case \"null\":\n if (value === null) return true;\n break;\n case \"emptyString\":\n if (value === \"\") return true;\n break;\n case \"whitespaceString\":\n // only matters if trimStrings is false; but still safe:\n if (typeof value === \"string\" && value.trim() === \"\") return true;\n break;\n case \"dash\":\n if (value === \"-\") return true;\n break;\n case \"nan\":\n if (typeof value === \"number\" && Number.isNaN(value)) return true;\n break;\n }\n }\n return false;\n}\n\nfunction shouldDropExact(value: unknown, exactValues?: unknown[]): boolean {\n if (!exactValues || exactValues.length === 0) return false;\n for (const v of exactValues) {\n if (Object.is(value, v)) return true;\n }\n return false;\n}\n\nfunction hasKey(list: string[] | undefined, key: string): boolean {\n return !!list && list.includes(key);\n}\n\nfunction sanitizeAny(\n input: unknown,\n options: Required<typeof DEFAULT_OPTIONS> & SanitizeOptions,\n path: KeyPath,\n): unknown {\n const normalized = normalizeValue(input, options);\n\n if (shouldDropPreset(normalized, options.drop)) return undefined;\n if (shouldDropExact(normalized, options.dropValues)) return undefined;\n if (options.shouldDrop?.(normalized, path)) return undefined;\n\n if (Array.isArray(normalized)) {\n if (!options.cleanArrays) return normalized.slice();\n const out: unknown[] = [];\n for (let i = 0; i < normalized.length; i++) {\n const next = sanitizeAny(normalized[i], options, path.concat(i));\n if (next !== undefined) out.push(next);\n }\n return out;\n }\n\n if (isPlainObject(normalized)) {\n if (!options.deep) {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(normalized)) {\n if (hasKey(options.dropKeys, k)) continue;\n if (hasKey(options.keepKeys, k)) {\n out[k] = v;\n continue;\n }\n const next = sanitizeAny(v, options, path.concat(k));\n if (next !== undefined) out[k] = next;\n }\n return out;\n }\n\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(normalized)) {\n if (hasKey(options.dropKeys, k)) continue;\n\n if (hasKey(options.keepKeys, k)) {\n out[k] = v;\n continue;\n }\n\n const next = sanitizeAny(v, options, path.concat(k));\n if (next !== undefined) out[k] = next;\n }\n return out;\n }\n\n return normalized;\n}\n\nexport function sanitize<T>(payload: T, options: SanitizeOptions = {}): T {\n const merged = {\n ...DEFAULT_OPTIONS,\n ...options,\n drop: options.drop ?? DEFAULT_OPTIONS.drop,\n };\n\n const result = sanitizeAny(payload, merged, []);\n\n if (result === undefined) {\n if (isPlainObject(payload)) return {} as T;\n if (Array.isArray(payload)) return [] as T;\n return payload;\n }\n\n return result as T;\n}\n\ntype SanitizerFn = {\n <T>(payload: T, options?: SanitizeOptions): T;\n with: (baseOptions?: SanitizeOptions) => ReturnType<typeof createSanitizer>;\n};\n\nexport const createSanitizer = (baseOptions: SanitizeOptions = {}) => {\n return <T>(payload: T, options: SanitizeOptions = {}) =>\n sanitize(payload, { ...baseOptions, ...options });\n};\n\n(sanitize as SanitizerFn).with = (baseOptions: SanitizeOptions = {}) =>\n createSanitizer(baseOptions);\n\nexport const sanitizeWith = (sanitize as SanitizerFn).with;\n"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "payload-sanitizer",
3
+ "version": "0.0.1",
4
+ "description": "Tiny zero-dependency payload sanitizer for JS/TS (frontend + backend).",
5
+ "keywords": [
6
+ "sanitize",
7
+ "payload",
8
+ "clean",
9
+ "typescript",
10
+ "utils"
11
+ ],
12
+ "license": "MIT",
13
+ "author": "Mohitul Islam",
14
+ "type": "module",
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.cjs"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "sideEffects": false,
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "dev": "tsup --watch",
34
+ "test": "vitest",
35
+ "typecheck": "tsc -p tsconfig.json --noEmit",
36
+ "lint": "eslint .",
37
+ "prepublishOnly": "pnpm build && pnpm test && pnpm typecheck"
38
+ },
39
+ "packageManager": "pnpm@10.29.3",
40
+ "devDependencies": {
41
+ "tsup": "^8.5.1",
42
+ "typescript": "^5.9.3",
43
+ "vitest": "^4.0.18"
44
+ },
45
+ "publishConfig": {
46
+ "access": "public"
47
+ }
48
+ }