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

Flexible Matcher Filter

Build a helper that filters path-like strings using mixed matching rules.

Capabilities

Supports mixed matcher types

  • A value equal to "logs/app.log" matches when matchers include that exact string. @test
  • "src/utils/math.js" matches when matchers include the glob "src/**/*.js". @test
  • "README.md" matches when matchers include a regular expression anchored to "^README". @test
  • "server.js" matches when matchers include a predicate that returns true for values containing "server". @test

Filters collections

  • Given ["src/index.js", "docs/guide.md", "scripts/build.mjs"] and matchers ["src/**/*.js", /\.md$/], returns ["src/index.js", "docs/guide.md"] preserving order. @test

Implementation

@generates

API

/**
 * Returns entries from `inputs` that satisfy at least one matcher.
 * @param {string[]} inputs
 * @param {string|RegExp|Function|(string|RegExp|Function)[]} matchers
 * @returns {string[]}
 */
export function filterMatches(inputs, matchers);
  • inputs is an array of strings to test.
  • matchers is a string, a glob string, a RegExp, a predicate function (value) => boolean, or an array combining them.
  • Matching is case-sensitive.
  • Returns a new array containing only the entries from inputs that satisfy at least one matcher.

Dependencies { .dependencies }

anymatch { .dependency }

Provides string, glob, regex, and predicate-based matching.

Install with Tessl CLI

npx tessl i tessl/npm-anymatch

tile.json