Skip to content

Commit

Permalink
Draft: update(replace) full curry typings (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harris-Miller authored Apr 2, 2024
1 parent 3976be8 commit ce48091
Showing 1 changed file with 47 additions and 4 deletions.
51 changes: 47 additions & 4 deletions types/replace.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,53 @@
import { Placeholder } from './util/tools';

// replace(pattern)
export function replace(pattern: RegExp | string): {
// replace(pattern)(replacement)(str)
(replacement: string | ((match: string, ...args: readonly any[]) => string)): (str: string) => string;
// replace(pattern)(__, str)(replacement)
(__: Placeholder, str: string): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => string;
// replace(pattern)(replacement, str)
(replacement: string | ((match: string, ...args: readonly any[]) => string), str: string): string;
};

// replace(__, replacement)
export function replace(__: Placeholder, replacement: string | ((match: string, ...args: readonly any[]) => string)): {
// replace(__, replacement)(pattern)(str)
(pattern: RegExp | string): (str: string) => string;
// replace(__, replacement)(__, str)(pattern)
(__: Placeholder, str: string): (pattern: RegExp | string) => string;
// replace(__, replacement)(pattern, str)
(pattern: RegExp | string, str: string): string;
};

// replace(pattern, replacement)(str)
export function replace(pattern: RegExp | string, replacement: string | ((match: string, ...args: readonly any[]) => string)): (str: string) => string;

// replace(__, __, str)
export function replace(__: Placeholder, __2: Placeholder, str: string): {
// replace(__, __, str)(pattern)(replacement)
(pattern: RegExp | string): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => string;
// replace(__, __, str)(__, replacement)(pattern)
(__: Placeholder, replacement: string | ((match: string, ...args: readonly any[]) => string)): (pattern: RegExp | string) => string;
// replace(__, __, str)(pattern, replacement)
(pattern: RegExp | string, replacement: string | ((match: string, ...args: readonly any[]) => string)): string;
};

// replace(__, replacement, str)(pattern)
export function replace(
pattern: RegExp | string,
): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => (str: string) => string;
__: Placeholder,
replacement: string | ((match: string, ...args: readonly any[]) => string),
str: string
): (pattern: RegExp | string) => string;

// replace(pattern, __, str)
export function replace(
pattern: RegExp | string,
replacement: string | ((match: string, ...args: readonly any[]) => string),
): (str: string) => string;
__: Placeholder,
str: string,
): (replacement: string | ((match: string, ...args: readonly any[]) => string)) => string;

// replace(pattern, replacement, str)
export function replace(
pattern: RegExp | string,
replacement: string | ((match: string, ...args: readonly any[]) => string),
Expand Down

0 comments on commit ce48091

Please sign in to comment.