All files / src/utils/omit omit.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 4/4

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18                  95x 216x 216x   891x        
import { IDictionary } from '@zeedhi/core';
 
/**
 * Removes a property from an object, returning the resulting object without
 * the property
 * @param obj object
 * @param key property to be removed
 * @returns object without said property
 */
export const omit = (obj: IDictionary, key: string | string[]) => {
	const keys = Array.isArray(key) ? key : [key];
	return Object.fromEntries(
    Object.entries(obj).filter(
      ([currentKey]) => !keys.includes(currentKey)
    )
  );
};