Your question is Write a NodeJS Addon. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Implement the matching algorithm behind a Node.js native addon used by GitHub to resolve CODEOWNERS-style ownership for repository paths. For every path, return the owner from the highest-precedence matching pattern, or None when no pattern matches.
Implement resolve_codeowners(patterns, paths). patterns is a list of objects with pattern and owner string fields. paths is a list of repository-relative POSIX paths. Return a list containing one owner string or None for each path.
Patterns are anchored at the repository root and are split on /. A segment containing * matches any sequence of characters except /; ? matches exactly one non-slash character. A segment equal to ** matches zero or more complete path segments. Patterns do not contain escaped characters.
A matching pattern wins by, in order: the greatest number of literal characters, the fewest wildcard tokens, then the greatest original pattern index. This makes ties follow the later CODEOWNERS rule.
/def resolve_codeowners(patterns, paths):