Skip to content

[Replacement]: object.omit #1200

Closed

Description

@outslept

Package to replace

object.omit

Package link

https://npmx.dev/object.omit

Suggested replacement

const omit = (obj, keys) =>
	Object.fromEntries(Object.entries(obj).filter(([k]) => ![keys].flat().includes(k)));
// or
const { a, b, ...rest } = obj;

// with a predicate fn
const omitBy = (obj, fn) =>
	Object.fromEntries(Object.entries(obj).filter(([k, v]) => fn(v, k, obj)));

Rationale

1 liner (maybe could be mapped to existing?)

Availability

No response

Code example

Activity

  1. 43081j commented on Nov 9, 2026

    @43081j
    Contributor

    i would just use the first one and simplify it. it doesn't need to flatten keys, just assume keys is already a flat array

  2. added
    accepted
    on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions