Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/ayonli_jsext/esm/object/index.js>sanitize

A JavaScript extension package for building strong and modern applications.
Latest
function sanitize
import { sanitize } from "https://deno.land/x/ayonli_jsext@v0.9.72/esm/object/index.js";

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

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
optional
deep = [UNSUPPORTED]
optional
options = [UNSUPPORTED]