(function() { var PathSeparator; PathSeparator = require('path').sep; exports.basenameMatch = function(string, query) { var base, index, lastCharacter, slashCount; index = string.length - 1; while (string[index] === PathSeparator) { index--; } slashCount = 0; lastCharacter = index; base = null; while (index >= 0) { if (string[index] === PathSeparator) { slashCount++; if (base == null) { base = string.substring(index + 1, lastCharacter + 1); } } else if (index === 0) { if (lastCharacter < string.length - 1) { if (base == null) { base = string.substring(0, lastCharacter + 1); } } else { if (base == null) { base = string; } } } index--; } return exports.match(base, query, string.length - base.length); }; exports.match = function(string, query, stringOffset) { var character, indexInQuery, indexInString, lowerCaseIndex, matches, minIndex, queryLength, stringLength, upperCaseIndex, _i, _ref, _results; if (stringOffset == null) { stringOffset = 0; } if (string === query) { return (function() { _results = []; for (var _i = stringOffset, _ref = stringOffset + string.length; stringOffset <= _ref ? _i < _ref : _i > _ref; stringOffset <= _ref ? _i++ : _i--){ _results.push(_i); } return _results; }).apply(this); } queryLength = query.length; stringLength = string.length; indexInQuery = 0; indexInString = 0; matches = []; while (indexInQuery < queryLength) { character = query[indexInQuery++]; lowerCaseIndex = string.indexOf(character.toLowerCase()); upperCaseIndex = string.indexOf(character.toUpperCase()); minIndex = Math.min(lowerCaseIndex, upperCaseIndex); if (minIndex === -1) { minIndex = Math.max(lowerCaseIndex, upperCaseIndex); } indexInString = minIndex; if (indexInString === -1) { return []; } matches.push(stringOffset + indexInString); stringOffset += indexInString + 1; string = string.substring(indexInString + 1, stringLength); } return matches; }; }).call(this);