UNPKG

es-next-tools

Version:

A comprehensive utility library for JavaScript and TypeScript that provides a wide range of functions for common programming tasks, including mathematical operations, date manipulations, array and object handling, string utilities, and more.

12 lines (11 loc) 371 B
export function omit(object, keysOrPredicate) { const shouldOmit = Array.isArray(keysOrPredicate) ? (key) => keysOrPredicate.includes(key) : (key) => keysOrPredicate(key, object[key]); return Object.keys(object).reduce((acc, key) => { if (!shouldOmit(key)) { acc[key] = object[key]; } return acc; }, {}); }