CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-anymatch

Matches strings against configurable strings, globs, regular expressions, and/or functions

76

1.11x
Overview
Eval results
Files

task.mdevals/scenario-5/

Input Filter Validator

Build a small helper that validates matcher configuration and evaluates paths using flexible matcher types while tolerating unsupported entries.

Capabilities

Valid matcher requirement

  • Creating an evaluator without at least one matcher throws a TypeError. @test

Test input validation

  • Passing anything other than a string or tuple [string, ...extras] to the evaluator throws a TypeError. @test

Tuple-aware matching

  • Given matchers that include a predicate expecting forwarded extras, supplying ["src/app.js", { lang: "js" }] returns true when the predicate approves the meta; plain string inputs that do not satisfy any matcher return false. @test

Tolerant unsupported matcher handling

  • Matcher lists may contain unsupported entries (e.g., numbers or objects); they never throw. If only unsupported entries are provided, evaluating "any/path.js" returns false. When supported matchers are present and returnIndex is requested, the evaluator reports the index of the first supported match while skipping unsupported entries. @test

Implementation

@generates

API

/**
 * Creates an evaluator for matching paths against flexible matchers.
 *
 * @param {string|RegExp|Function|(string|RegExp|Function)[]} matchers - Required matchers to test paths against.
 * @param {object} [options] - Optional matching options passed to the underlying matcher engine.
 * @returns {(value: string | [string, ...unknown[]], opts?: { returnIndex?: boolean }) => boolean | number}
 * A function that evaluates a test value and returns either a boolean or the index of the first matching matcher (or -1 when none match) when returnIndex is true.
 */
export function createEvaluator(matchers, options) {}

Dependencies { .dependencies }

anymatch { .dependency }

Matches strings against glob, regexp, or predicate matchers while supporting optional return of the matching index and tolerant handling of unsupported matcher entries.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-anymatch

tile.json