Skip to content

Commit

Permalink
Adding typing for swap function
Browse files Browse the repository at this point in the history
  • Loading branch information
ranneyd committed Jun 2, 2023
1 parent 531a662 commit ee672b7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions types/swap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Placeholder } from './util/tools';

// swap(indexA, indexB, list)
export function swap<T>(indexA: number, indexB: number, list: readonly T[]): T[];
// swap(indexA, indexB)(list)
export function swap<T>(indexA: number, indexB: number): (list: readonly T[]) => T[];
// swap(indexA)
export function swap(indexA: number): {
// swap(indexA)(indexB, list)
<T>(indexB: number, list: readonly T[]): T[];
// swap(indexA)(__, list)(indexB)
<T>(__: Placeholder, list: readonly T[]): (indexB: number) => T[];
// swap(indexA)(indexB)(list)
<T>(indexB: number): (list: readonly T[]) => T[];
};

// swap(__, indexB, list)(indexA)
export function swap<T>(
__: Placeholder,
indexB: number,
list: readonly T[]
): (indexA: number) => T[];
// swap(indexA, __, list)(indexB)
export function swap<T>(
indexA: number,
__: Placeholder,
list: readonly T[]
): (indexB: number) => T[];
// swap(__, __, list)
export function swap<T>(
__: Placeholder,
__2: Placeholder,
list: readonly T[]
): {
// swap(__, __, list)(indexA, indexB)
(indexA: number, indexB: number): T[];
// swap(__, __, list)(__, indexB)(indexA)
(__3: Placeholder, indexB: number): (indexA: number) => T[];
// swap(__, __, list)(indexA)(indexB)
(indexA: number): (indexB: number) => T[];
};

0 comments on commit ee672b7

Please sign in to comment.