Skip to content

@jsvision/files / wildcardMatch

Function: wildcardMatch()

wildcardMatch(pattern, name): boolean

Defined in: files/src/fs/wildcard.ts:44

Match a whole name against a */? pattern, case-sensitively ("*.*" behaves as "*").

Parameters

pattern

string

The wildcard pattern, e.g. '*.ts' or 'file?.txt'.

name

string

The candidate filename.

Returns

boolean

Whether the entire name matches the entire pattern.

Example

ts
import { wildcardMatch } from '@jsvision/files';

wildcardMatch('*.ts', 'main.ts');    // → true
wildcardMatch('*.ts', 'main.tsx');   // → false
wildcardMatch('file?.txt', 'file1.txt'); // → true
wildcardMatch('*.*', 'README');      // → true  ("*.*" matches extensionless names)