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-8/

Reusable Matcher Utility

Builds a curried matcher from mixed criteria and reuses it for repeated filtering of path-like strings.

Capabilities

Curried tester from mixed matchers

  • Creating one tester from a glob and a regex returns true for matching paths like src/utils/file.js and false for non-matching entries like README.md, even when reused across multiple invocations. @test

Predicate and array forwarding

  • The tester accepts array input where the first element is matched while remaining elements flow into a predicate matcher to enforce extra constraints. @test

Return index on demand

  • Invoking the tester with returnIndex yields the index of the first matching matcher (e.g., 1 for a regex hit) or -1 when nothing matches. @test

Filtering with reusable tester

  • Using the curried tester as a filter callback over a list keeps only matching entries, demonstrating reuse without rebuilding the matcher. @test

Implementation

@generates

API

/**
 * Builds a reusable matcher from a list of matchers and optional glob options.
 * @param {Array<string|RegExp|Function>|string|RegExp|Function} matchers
 * @param {object} [options]
 * @returns {(value: string|string[], returnIndex?: boolean) => boolean|number}
 */
export function createReusableTester(matchers, options);

/**
 * Filters a list of values using a reusable tester; when returnIndex is true it maps to matcher indices instead of values.
 * @param {Array<string|string[]>} values
 * @param {(value: string|string[], returnIndex?: boolean) => boolean|number} tester
 * @param {boolean} [returnIndex]
 * @returns {Array<string|number>}
 */
export function filterWithTester(values, tester, returnIndex);

Dependencies { .dependencies }

anymatch { .dependency }

Provides curried matcher generation for strings, globs, regexes, and predicate functions.

Install with Tessl CLI

npx tessl i tessl/npm-anymatch

tile.json