diff --git a/index.d.ts b/index.d.ts index 56491fa..2eaea05 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,9 +2,9 @@ import sep from 'path'; -type AnymatchFn = (string:string) => boolean; +type AnymatchFn = (string) => boolean; type AnymatchPattern = string|RegExp|AnymatchFn; type AnymatchMatcher = AnymatchPattern|Array -declare function anymatch(matchers: AnymatchMatcher, testString: string, returnIndex?: boolean): boolean; -declare function anymatch(matchers: AnymatchMatcher): (testString: string, returnIndex?: boolean) => number; +declare function anymatch(matchers: AnymatchMatcher, testString: string|Array, returnIndex?: boolean): boolean; +declare function anymatch(matchers: AnymatchMatcher): (testString: string|Array, returnIndex?: boolean) => number; export = anymatch; \ No newline at end of file diff --git a/index.js b/index.js index 204f42a..623d161 100644 --- a/index.js +++ b/index.js @@ -67,9 +67,9 @@ const matchPatterns = (patterns, negatedGlobs, path, returnIndex) => { /** * @param {AnymatchMatcher} matchers - * @param {String|Array} testString + * @param {Array|string} testString * @param {Boolean=} returnIndex - * @returns {boolean|Number|Function} + * @returns {boolean|number|Function} */ const anymatch = (matchers, testString, returnIndex = false) => { if (matchers == null) { diff --git a/test.js b/test.js index 6a9f479..9106b31 100644 --- a/test.js +++ b/test.js @@ -105,26 +105,26 @@ describe('anymatch', () => { it('should pass extra args to function matchers', () => { matchers.push((string, arg1, arg2) => arg1 || arg2); - assert(!anymatch(matchers, 'bar.js'), 1); - assert(!anymatch(matchers, ['bar.js', 0]), 2); - assert(anymatch(matchers, ['bar.js', true]), 3); - assert(anymatch(matchers, ['bar.js', 0, true]), 4); + assert(!anymatch(matchers, 'bar.js'), '1'); + assert(!anymatch(matchers, ['bar.js', 0]), '2'); + assert(anymatch(matchers, ['bar.js', true]), '3'); + assert(anymatch(matchers, ['bar.js', 0, true]), '4'); // with returnIndex - assert.equal(anymatch(matchers, ['bar.js', 1], true), 4, 5); + assert.equal(anymatch(matchers, ['bar.js', 1], true), 4, '5'); // curried versions var matchFn1 = anymatch(matchers); var matchFn2 = anymatch(matchers[4]); - assert(!matchFn1(['bar.js', 0]), 6); - assert(!matchFn2(['bar.js', 0]), 7); - assert(matchFn1(['bar.js', true]), 8); - assert(matchFn2(['bar.js', true]), 9); - assert(matchFn1(['bar.js', 0, true]), 10); - assert(matchFn2(['bar.js', 0, true]), 11); + assert(!matchFn1(['bar.js', 0]), '6'); + assert(!matchFn2(['bar.js', 0]), '7'); + assert(matchFn1(['bar.js', true]), '8'); + assert(matchFn2(['bar.js', true]), '9'); + assert(matchFn1(['bar.js', 0, true]), '10'); + assert(matchFn2(['bar.js', 0, true]), '11'); // curried with returnIndex - assert.equal(matchFn1(['bar.js', 1], true), 4, 12); - assert.equal(matchFn2(['bar.js', 1], true), 0, 13); - assert.equal(matchFn1(['bar.js', 0], true), -1, 14); - assert.equal(matchFn2(['bar.js', 0], true), -1, 15); + assert.equal(matchFn1(['bar.js', 1], true), 4, '12'); + assert.equal(matchFn2(['bar.js', 1], true), 0, '13'); + assert.equal(matchFn1(['bar.js', 0], true), -1, '14'); + assert.equal(matchFn2(['bar.js', 0], true), -1, '15'); matchers.pop(); }); });