Skip to content

Commit b98bfd6

Browse files
committed
feat: Remove GetAllOptions and filterInvalid
Per feedback on plexinc#979
1 parent 3cac6f0 commit b98bfd6

File tree

2 files changed

+5
-28
lines changed

2 files changed

+5
-28
lines changed

src/__tests__/utils.test.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
PropertyType,
1010
getDefaultValues,
1111
ObjectIdConstructorParameter,
12-
GetIdsOptions,
1312
} from '../utils';
1413

1514
describe('utils', () => {
@@ -385,7 +384,6 @@ describe('utils', () => {
385384
string,
386385
{
387386
input: readonly ObjectIdConstructorParameter[];
388-
options?: GetIdsOptions;
389387
expected: readonly ObjectId[];
390388
},
391389
]
@@ -440,18 +438,17 @@ describe('utils', () => {
440438
'invalid values, when filterInvalid is true',
441439
{
442440
input: ['123', '123456789012345678900021'],
443-
options: { filterInvalid: true },
444441
expected: [new ObjectId('123456789012345678900021')],
445442
},
446443
],
447-
])('should return ObjectIds from %s', (_name, { input, options, expected }) => {
444+
])('should return ObjectIds from %s', (_name, { input, expected }) => {
448445
expect.assertions(4);
449446

450447
// Given
451448
expect(expected.length).toBeLessThanOrEqual(input.length);
452449

453450
// When
454-
const actual = getIds(input, options);
451+
const actual = getIds(input);
455452

456453
// Then
457454
expect(actual).toEqual(expected);
@@ -464,17 +461,5 @@ describe('utils', () => {
464461
);
465462
expect(isEveryHexEquivalent).toBeTruthy();
466463
});
467-
468-
test('should throw on invalid values, when filterInvalid is unspecified', () => {
469-
expect.assertions(1);
470-
471-
// Given
472-
const input = ['123', '123456789012345678900021'];
473-
474-
// When/Then
475-
expect(() => getIds(input)).toThrowErrorMatchingInlineSnapshot(
476-
'"input must be a 24 character hex string, 12 byte Uint8Array, or an integer"'
477-
);
478-
});
479464
});
480465
});

src/utils.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,20 +195,12 @@ export type RequireAtLeastOne<TObj, Keys extends keyof TObj = keyof TObj> = {
195195
Pick<TObj, Exclude<keyof TObj, Keys>>;
196196

197197
export type ObjectIdConstructorParameter = ConstructorParameters<typeof ObjectId>[0];
198-
export interface GetIdsOptions {
199-
filterInvalid?: boolean;
200-
}
201-
export function getIds(
202-
ids: Iterable<ObjectIdConstructorParameter>,
203-
options?: GetIdsOptions
204-
): ObjectId[] {
198+
export function getIds(ids: Iterable<ObjectIdConstructorParameter>): ObjectId[] {
205199
return Array.from(ids).flatMap((id) => {
206200
try {
207201
return new ObjectId(id);
208-
} catch (error) {
209-
if (!options?.filterInvalid) {
210-
throw error;
211-
}
202+
} catch {
203+
// Intentionally empty
212204
}
213205

214206
return [];

0 commit comments

Comments
 (0)