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

File Event Selector

Build a small utility that filters filesystem-like event tuples using flexible matcher rules. Each event is represented as [path, eventType, ...metadata]. The first tuple element is always matched as the path; the remaining elements must be forwarded into predicate matchers so they can make decisions using the extra context.

Capabilities

Filters events by path rules

  • Given events ["src/index.js", "change"] and ["README.md", "change"] and matchers containing a glob that targets JavaScript files, filtering returns only the JavaScript event. @test

Forwards metadata to predicate matchers

  • With matchers containing a predicate that returns true only when the event type is "unlink", filtering ["src/app.js", "add"] and ["src/app.js", "unlink"] returns only the unlink event because the predicate receives the forwarded event type argument. @test

Combines string/glob and predicate rules

  • With matchers including a negated glob that excludes temporary files and a predicate that checks the third tuple value for the string "ci", filtering ["tmp/app.tmp", "change", "ci"], ["src/app.js", "change", "dev"], and ["src/app.js", "change", "ci"] returns only ["src/app.js", "change", "ci"]. String/glob matchers apply to the path while predicate matchers see all forwarded tuple elements. @test

Implementation

@generates

API

Expose a reusable tester and a helper that filters arrays of event tuples. When options.returnIndex is true, the tester returns the index of the first matching rule or -1 when nothing matches. In index mode the filter helper returns { event, matchIndex } objects for matches and skips anything that does not match.

export type EventTuple = [string, ...any[]];

export interface MatchOptions {
  returnIndex?: boolean;
}

export function createEventTester(
  matchers: Array<string | RegExp | ((path: string, ...meta: any[]) => boolean)>,
  options?: MatchOptions
): (event: EventTuple) => boolean | number;

export function filterEvents(
  events: EventTuple[],
  matchers: Array<string | RegExp | ((path: string, ...meta: any[]) => boolean)>,
  options?: MatchOptions
): EventTuple[] | Array<{ event: EventTuple; matchIndex: number }>;

Dependencies { .dependencies }

anymatch { .dependency }

Matches event paths against strings, globs, regular expressions, or predicate rules and forwards any additional tuple elements into predicate matchers.

Version

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