Skip to content

Commit

Permalink
refactor: rename dir argument to direction
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Jul 2, 2024
1 parent de23cb4 commit a639b48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/array/alphabetical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
export function alphabetical<T>(
array: readonly T[],
getter: (item: T) => string,
dir: 'asc' | 'desc' = 'asc',
direction: 'asc' | 'desc' = 'asc',
): T[] {
if (!array) {
return []
}
const asc = (a: T, b: T) => `${getter(a)}`.localeCompare(getter(b))
const dsc = (a: T, b: T) => `${getter(b)}`.localeCompare(getter(a))
return array.slice().sort(dir === 'desc' ? dsc : asc)
return array.slice().sort(direction === 'desc' ? dsc : asc)
}

0 comments on commit a639b48

Please sign in to comment.