CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-picomatch

Blazing fast and accurate glob matcher written in JavaScript, with no dependencies and full support for standard and extended Bash glob features, including braces, extglobs, POSIX brackets, and regular expressions.

83

1.45x
Overview
Eval results
Files

task.mdevals/scenario-9/

Custom Range Pattern Matcher

Build a pattern matching utility that supports custom numeric range expansion in glob patterns.

Requirements

Your utility should:

  1. Create a pattern matcher that accepts glob patterns with numeric ranges in the format {start..end}
  2. Support custom range expansion logic that generates zero-padded numbers (e.g., {1..3} expands to match "01", "02", "03")
  3. Match file paths against patterns containing these custom ranges
  4. Return true if the path matches the pattern, false otherwise

Behavior

The matcher should:

  • Accept patterns like file{1..5}.txt which should match files like "file01.txt", "file02.txt", through "file05.txt"
  • Handle patterns with ranges in different positions (e.g., logs/session{10..12}/data.log)
  • Use zero-padding to make all numbers in a range the same width (based on the end number's width)
  • Work with standard glob wildcards (*, ?) in combination with custom ranges

Test Cases

  • Matching "file01.txt" against pattern "file{1..3}.txt" returns true @test
  • Matching "file04.txt" against pattern "file{1..3}.txt" returns false @test
  • Matching "logs/session10/data.log" against pattern "logs/session{8..12}/data.log" returns true @test
  • Matching "report-05.pdf" against pattern "report-{1..10}.pdf" returns true @test

@generates

API

/**
 * Creates a matcher function with custom range expansion support.
 *
 * @param {string} pattern - A glob pattern that may contain numeric ranges like {start..end}
 * @returns {Function} A function that tests if a string matches the pattern
 */
function createMatcher(pattern) {
  // Implementation
}

module.exports = { createMatcher };

Dependencies { .dependencies }

picomatch { .dependency }

Provides glob pattern matching capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-picomatch

tile.json