CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-anymatch

tessl install tessl/npm-anymatch@3.1.0

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

Agent Success

Agent success rate when using this tile

76%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.12x

Baseline

Agent success rate without this tile

68%

task.mdevals/scenario-3/

Pattern Match Evaluator

Utility for evaluating strings or path-like inputs against mixed matcher definitions, with results available as a boolean or as the index of the first match.

Capabilities

Direct checks

  • Given an array of matcher definitions and a test value, it returns true when any matcher applies and false otherwise. @test
  • When invoked in index mode, it returns the zero-based index of the first matcher that applies, or -1 when nothing matches. @test

Reusable tester

  • It builds a reusable tester from matcher definitions that can be used repeatedly on inputs, producing booleans by default or indices when requested per invocation. @test
  • The reusable tester works as an Array.prototype.filter callback to keep only matching entries in boolean mode. @test

Implementation

@generates

API

/**
 * Checks whether the provided value satisfies any matcher.
 *
 * @param {Array<string|RegExp|Function>|string|RegExp|Function} matchers - Single matcher or list of matcher definitions.
 * @param {string|any[]} value - A string to test, or an array where the first element is tested and the rest are forwarded to function matchers.
 * @param {{ mode?: 'boolean' | 'index' }} [options] - Controls whether the result is a boolean or a match index.
 * @returns {boolean|number} Boolean by default; when mode is "index" returns the index of the first matching matcher or -1.
 */
export function checkMatch(matchers, value, options);

/**
 * Creates a reusable tester for the provided matchers.
 *
 * @param {Array<string|RegExp|Function>|string|RegExp|Function} matchers - Matcher definitions.
 * @returns {(value: string|any[], options?: { mode?: 'boolean' | 'index' }) => boolean|number} Tester usable directly or as a filter callback.
 */
export function createMatchTester(matchers);

Dependencies { .dependencies }

anymatch { .dependency }

Provides matcher evaluation with support for boolean or index-style results.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/anymatch@3.1.x
tile.json