Skip to content

Commit

Permalink
Update: match (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
Harris-Miller authored Oct 11, 2023
1 parent ee3f101 commit 486db95
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 8 additions & 0 deletions test/match.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expectType } from 'tsd';

import { __, match } from '../es';

// not much to test here
expectType<RegExpMatchArray>(match(/foo/, 'foo'));
expectType<RegExpMatchArray>(match(/foo/)('foo'));
expectType<RegExpMatchArray>(match(__, 'foo')(/foo/));
9 changes: 7 additions & 2 deletions types/match.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
export function match(regexp: RegExp): (str: string) => string[];
export function match(regexp: RegExp, str: string): string[];
import { Placeholder } from './util/tools';

// ramda used `Array.prototype.match` in its implementation, but never returns undefined
// See: https://github.com/ramda/ramda/blob/v0.29.1/source/match.js#L26
export function match(regexp: RegExp): (str: string) => RegExpMatchArray;
export function match(__: Placeholder, str: string): (regexp: RegExp) => RegExpMatchArray;
export function match(regexp: RegExp, str: string): RegExpMatchArray;

0 comments on commit 486db95

Please sign in to comment.