Skip to content

Commit 2b7e7cb

Browse files
committed
chore: return early when input is empty
1 parent 966b488 commit 2b7e7cb

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

src/pathParts.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
export function* pathParts(input: PropertyKey): Generator<PropertyKey> {
2+
if (input === '') {
3+
return;
4+
}
5+
26
if (typeof input !== 'string') {
37
yield input;
48

test/pathParts.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ describe('pathParts()', () => {
2323
it('returns input for non-string input', () => {
2424
expect(Array.from(pathParts(123))).toEqual([123]);
2525
});
26+
27+
it('returns empty array for empty string input', () => {
28+
expect(Array.from(pathParts(''))).toEqual([]);
29+
});
2630
});

0 commit comments

Comments
 (0)