omit
Creates a new object with the specified keys removed. Supports dot notation for removing nested keys.
Import
Section titled “Import”import { omit } from "1o1-utils";import { omit } from "1o1-utils/omit";Signature
Section titled “Signature”function omit<T extends Record<string, unknown>>({ obj, keys }: OmitParams<T>): Record<string, unknown>Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
obj | T | Yes | The source object |
keys | (keyof T | string)[] | Yes | Keys to exclude (supports dot notation for nested keys) |
Returns
Section titled “Returns”Record<string, unknown> — A new object without the specified keys.
Examples
Section titled “Examples”omit({ obj: { a: 1, b: 2, c: 3 }, keys: ["b", "c"] });// => { a: 1 }
// Nested keys with dot notationomit({ obj: { a: 1, b: { x: 10, y: 20 } }, keys: ["b.x"] });// => { a: 1, b: { y: 20 } }Edge Cases
Section titled “Edge Cases”- Throws if
objis not an object. - Throws if
keysis not an array. - Supports nested key removal via dot notation.
- Does not mutate the original object.
Also known as
Section titled “Also known as”exclude keys, remove properties, without keys, strip fields
Prompt suggestion
Section titled “Prompt suggestion”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