import { sanitize } from "https://deno.land/x/ayonli_jsext@v0.9.72/object/index.ts";
Creates an object base on the original object but without any invalid values
(except for null
), and trims the value if it's a string.
NOTE: This function only operates on plain objects and arrays.
Examples
Example 1
Example 1
import { sanitize } from "@ayonli/jsext/object";
const obj = sanitize({
foo: "Hello",
bar: " World ",
baz: undefined,
num: NaN,
});
console.log(obj); // { foo: "Hello", bar: "World" }
Parameters
obj: T