Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
victory-sokolov committed Jun 13, 2024
1 parent ae6fb8c commit 04576aa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
34 changes: 17 additions & 17 deletions src/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ import type { RecordObject } from './types';
* @returns Object with keys removed
*/
export const omit = <T extends Record<string, any>, K extends keyof T>(
objOrArray: T | T[],
...keys: K[]
objOrArray: T | T[],
...keys: K[]
): T | T[] => {
// Function to remove keys from a single object
const omitKeysFromObject = (obj: T): T => {
const newObj = { ...obj };
keys.forEach((key) => {
delete newObj[key];
});
return newObj;
};
// Function to remove keys from a single object
const omitKeysFromObject = (obj: T): T => {
const newObj = { ...obj };
keys.forEach((key) => {
delete newObj[key];
});
return newObj;
};

// Check if input is an array of objects
if (Array.isArray(objOrArray)) {
return objOrArray.map(omitKeysFromObject);
} else {
// Input is a single object
return omitKeysFromObject(objOrArray);
}
// Check if input is an array of objects
if (Array.isArray(objOrArray)) {
return objOrArray.map(omitKeysFromObject);
} else {
// Input is a single object
return omitKeysFromObject(objOrArray);
}
};

/**
Expand Down
10 changes: 5 additions & 5 deletions tests/object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ describe('omit', () => {
expect(omit(obj, 'a', 'c')).toEqual({ b: 2 });
});
it("should remove keys from array of objects", () => {

Check failure on line 16 in tests/object.test.ts

View workflow job for this annotation

GitHub Actions / lint-test

Strings must use singlequote
const obj = [
{ a: 1, b: 2, c: 3 },
{ a: 4, b: 5, c: 6 },
];
expect(omit(obj, "a", "c")).toEqual([{ b: 2 }, { b: 5 }]);
const obj = [
{ a: 1, b: 2, c: 3 },
{ a: 4, b: 5, c: 6 },
];
expect(omit(obj, 'a', 'c')).toEqual([{ b: 2 }, { b: 5 }]);
});
});

Expand Down

0 comments on commit 04576aa

Please sign in to comment.