Skip to content

omit

Creates a new object with the specified keys removed. Supports dot notation for removing nested keys.

import { omit } from "1o1-utils";
import { omit } from "1o1-utils/omit";
function omit<T extends Record<string, unknown>>({ obj, keys }: OmitParams<T>): Record<string, unknown>
NameTypeRequiredDescription
objTYesThe source object
keys(keyof T | string)[]YesKeys to exclude (supports dot notation for nested keys)

Record<string, unknown> — A new object without the specified keys.

omit({ obj: { a: 1, b: 2, c: 3 }, keys: ["b", "c"] });
// => { a: 1 }
// Nested keys with dot notation
omit({ obj: { a: 1, b: { x: 10, y: 20 } }, keys: ["b.x"] });
// => { a: 1, b: { y: 20 } }
  • Throws if obj is not an object.
  • Throws if keys is not an array.
  • Supports nested key removal via dot notation.
  • Does not mutate the original object.

exclude keys, remove properties, without keys, strip fields

I'm using 1o1-utils (npm: https://www.npmjs.com/package/1o1-utils, GitHub: https://github.com/pedrotroccoli/1o1-utils, LLM context: https://pedrotroccoli.github.io/1o1-utils/llms.txt). Show me how to use omit to strip sensitive fields before logging