Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/compat/object/invertBy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { isUnsafeProperty } from '../../_internal/isUnsafeProperty.ts';
import { identity } from '../../function/identity.ts';
import { isNil } from '../../predicate/isNil.ts';
import { ValueIteratee } from '../_internal/ValueIteratee.ts';
Expand Down Expand Up @@ -85,9 +86,13 @@
for (let i = 0; i < keys.length; i++) {
const key = keys[i] as string;

const value = (object as any)[key];

Check warning on line 89 in src/compat/object/invertBy.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
const valueStr = getString(value);

if (isUnsafeProperty(valueStr)) {
continue;
}

if (Array.isArray(result[valueStr])) {
result[valueStr].push(key);
} else {
Expand Down
5 changes: 5 additions & 0 deletions src/object/invert.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isUnsafeProperty } from '../_internal/isUnsafeProperty';

/**
* Inverts the keys and values of an object. The keys of the input object become the values of the output object and vice versa.
*
Expand All @@ -24,6 +26,9 @@ export function invert<K extends PropertyKey, V extends PropertyKey>(obj: Record
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const value = obj[key];
if (isUnsafeProperty(value)) {
continue;
}
result[value] = key;
}

Expand Down