[Pkg-javascript-commits] [node-multimatch] 01/03: Import Upstream version 2.1.0

Sruthi Chandran srud-guest at moszumanska.debian.org
Thu Nov 3 18:20:53 UTC 2016


This is an automated email from the git hooks/post-receive script.

srud-guest pushed a commit to branch master
in repository node-multimatch.

commit ca0f5caa866657ae37e6f4a6150a54d74b784282
Author: Sruthi <srud at disroot.org>
Date:   Thu Nov 3 23:06:32 2016 +0530

    Import Upstream version 2.1.0
---
 .editorconfig  |  16 +++++
 .gitattributes |   1 +
 .gitignore     |   1 +
 .jshintrc      |  13 ++++
 .travis.yml    |   6 ++
 index.js       |  27 ++++++++
 license        |  21 ++++++
 package.json   |  50 ++++++++++++++
 readme.md      |  62 +++++++++++++++++
 test.js        | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 10 files changed, 408 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8311fe1
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+# editorconfig.org
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[package.json]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..804f8af
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,13 @@
+{
+	"node": true,
+	"esnext": true,
+	"bitwise": true,
+	"camelcase": true,
+	"curly": true,
+	"immed": true,
+	"newcap": true,
+	"noarg": true,
+	"undef": true,
+	"unused": "vars",
+	"strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dedfc07
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+sudo: false
+language: node_js
+node_js:
+  - 'iojs'
+  - '0.12'
+  - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..6adc678
--- /dev/null
+++ b/index.js
@@ -0,0 +1,27 @@
+'use strict';
+var minimatch = require('minimatch');
+var arrayUnion = require('array-union');
+var arrayDiffer = require('array-differ');
+var arrify = require('arrify');
+
+module.exports = function (list, patterns, options) {
+	list = arrify(list);
+	patterns = arrify(patterns);
+
+	if (list.length === 0 || patterns.length === 0) {
+		return [];
+	}
+
+	options = options || {};
+
+	return patterns.reduce(function (ret, pattern) {
+		var process = arrayUnion;
+
+		if (pattern[0] === '!') {
+			pattern = pattern.slice(1);
+			process = arrayDiffer;
+		}
+
+		return process(ret, minimatch.match(list, pattern, options));
+	}, []);
+};
diff --git a/license b/license
new file mode 100644
index 0000000..5ec444d
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus, Jon Schlinkert, contributors.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..4fb389f
--- /dev/null
+++ b/package.json
@@ -0,0 +1,50 @@
+{
+  "name": "multimatch",
+  "version": "2.1.0",
+  "description": "Extends minimatch.match() with support for multiple patterns",
+  "license": "MIT",
+  "repository": "sindresorhus/multimatch",
+  "author": {
+    "email": "sindresorhus at gmail.com",
+    "name": "Sindre Sorhus",
+    "url": "http://sindresorhus.com"
+  },
+  "maintainers": [
+    {
+      "name": "Jon Schlinkert",
+      "url": "https://github.com/jonschlinkert"
+    }
+  ],
+  "engines": {
+    "node": ">=0.10.0"
+  },
+  "scripts": {
+    "test": "mocha"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "expand",
+    "find",
+    "glob",
+    "globbing",
+    "globs",
+    "match",
+    "matcher",
+    "minimatch",
+    "pattern",
+    "patterns",
+    "wildcard"
+  ],
+  "dependencies": {
+    "array-differ": "^1.0.0",
+    "array-union": "^1.0.1",
+    "arrify": "^1.0.0",
+    "minimatch": "^3.0.0"
+  },
+  "devDependencies": {
+    "chai": "^3.4.1",
+    "mocha": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..f10fa5d
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,62 @@
+# multimatch [![Build Status](https://travis-ci.org/sindresorhus/multimatch.svg?branch=master)](https://travis-ci.org/sindresorhus/multimatch)
+
+> Extends [`minimatch.match()`](https://github.com/isaacs/minimatch#minimatchmatchlist-pattern-options) with support for multiple patterns
+
+
+## Install
+
+```sh
+
+$ npm install --save multimatch
+```
+
+
+## Usage
+
+```js
+var multimatch = require('multimatch');
+
+multimatch(['unicorn', 'cake', 'rainbows'], ['*', '!cake']);
+//=> ['unicorn', 'rainbows']
+```
+
+See the [tests](https://github.com/sindresorhus/multimatch/blob/master/test.js) for more usage examples and expected matches.
+
+
+## API
+
+Same as [`minimatch.match()`](https://github.com/isaacs/minimatch#minimatchmatchlist-pattern-options) except for `pattern` also accepting an array.
+
+```js
+var results = multimatch(paths, patterns);
+```
+
+The return value is an array of matching paths.
+
+
+## How multiple patterns work
+
+Positive patterns (e.g. `foo` or `*`) add to the results, while negative patterns (e.g. `!foo`) subtract from the results.
+
+Therefore a lone negation (e.g. `['!foo']`) will never match anything – use `['*', '!foo']` instead.
+
+
+## Globbing patterns
+
+Just a quick overview.
+
+- `*` matches any number of characters, but not `/`
+- `?` matches a single character, but not `/`
+- `**` matches any number of characters, including `/`, as long as it's the only thing in a path part
+- `{}` allows for a comma-separated list of "or" expressions
+- `!` at the beginning of a pattern will negate the match
+
+
+## Related
+
+See [globby](https://github.com/sindresorhus/globby) if you need to match against the filesystem instead of a list.
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com), [Jon Schlinkert](https://github.com/jonschlinkert)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..ece2d0e
--- /dev/null
+++ b/test.js
@@ -0,0 +1,211 @@
+'use strict';
+var expect = require('chai').expect;
+var mm = require('./');
+
+describe('when an array of additive glob patterns is defined:', function () {
+	it('should match on multiple patterns', function () {
+		expect(mm(['unicorn', 'cake', 'rainbows'], ['*', '!cake'])).to.eql(['unicorn', 'rainbows']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', 'bar'])).to.eql(['foo', 'bar']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!bar'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', 'bar'])).to.eql(['bar']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', '!bar'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['!*{o,r}', 'foo'])).to.eql(['foo']);
+	});
+
+	it('should return an array of matches', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['f*'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['f*', 'bar'])).to.eql(['foo', 'bar']);
+	});
+
+	it('should return matches in the order the patterns were defined', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['bar', 'f*'])).to.eql(['bar', 'foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['f*', '*z'])).to.eql(['foo', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*z', 'f*'])).to.eql(['baz', 'foo']);
+	});
+});
+
+describe('when additive string patterns are defined and matches are found:', function () {
+	it('should return an array of matches', function () {
+		expect(mm(['foo', 'bar', 'baz'], 'foo')).to.eql(['foo']);
+	});
+});
+
+describe('when negation string patterns are defined', function () {
+	it('should return an array with negations omitted', function () {
+		expect(mm(['foo', 'bar', 'baz'], '!foo')).to.eql([]);
+	});
+});
+
+describe('when an array of additive string patterns is defined and matches are found:', function () {
+	it('should return an array of matches', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['foo', 'bar'])).to.eql(['foo', 'bar']);
+	});
+
+	it('should return an empty array when no matches are found', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['quux'])).to.eql([]);
+	});
+});
+
+describe('when an array of negation glob patterns is defined', function () {
+	it('should return an array with negations omitted', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!*z'])).to.eql([]);
+	});
+
+	it('should return an array with negations omitted', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!*z', '!*a*'])).to.eql([]);
+	});
+
+	it('should return an empty array when no matches are found', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!*'])).to.eql([]);
+	});
+});
+
+describe('when an array of filepaths is passed, and an array of negation glob patterns is defined', function () {
+	var fixtures = ['vendor/js/foo.js', 'vendor/js/bar.js', 'vendor/js/baz.js'];
+
+	it('should return an array with negations omitted', function () {
+		expect(mm(fixtures, ['!**/*z.js'])).to.eql([]);
+	});
+
+	it('should return an array with negations omitted', function () {
+		expect(mm(fixtures, ['!**/*z.js', '**/foo.js'])).to.eql(['vendor/js/foo.js']);
+	});
+
+	it('should return an array with negations omitted', function () {
+		expect(mm(fixtures, ['!**/*z.js', '!**/*a*.js'])).to.eql([]);
+	});
+
+	it('should return an empty array when no matches are found', function () {
+		expect(mm(fixtures, ['!**/*.js'])).to.eql([]);
+	});
+});
+
+describe('when an array of negation string patterns is defined', function () {
+	it('should return an array with negations omitted', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!foo'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', '!bar'])).to.eql([]);
+	});
+});
+
+describe('when inclusion and negation patterns are defined', function () {
+	it('should return an array of matches, sans negations', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!*a*'])).to.eql([]);
+	});
+
+	it('patterns should be order sensitive', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!*a*', '*z'])).to.eql(['baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*z', '!*a*'])).to.eql([]);
+		expect(mm(['foo', 'foam', 'for', 'forum'], ['!*m', 'f*'])).to.eql(['foo', 'foam', 'for', 'forum']);
+		expect(mm(['foo', 'foam', 'for', 'forum'], ['f*', '!*m'])).to.eql(['foo', 'for']);
+		expect(mm(['foo', 'bar', 'baz'], ['!*{o,r}', 'foo'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!*{o,r}'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', 'bar'])).to.eql(['bar']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!bar'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['bar', '!foo', 'foo'])).to.eql(['bar', 'foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!foo', 'bar'])).to.eql(['bar']);
+	});
+
+	it('should override negations and re-include explicitly defined patterns', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['!*'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['!*a*'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['bar', '!*a*'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['!*a*', 'bar'])).to.eql(['bar']);
+		expect(mm(['foo', 'bar', 'baz'], ['!*a*', '*'])).to.eql(['foo', 'bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['!*a*', '*z'])).to.eql(['baz']);
+	});
+});
+
+describe('misc', function () {
+	it('misc', function () {
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!foo'])).to.eql(['bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!foo', 'bar'])).to.eql(['bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!foo'])).to.eql(['bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', '*'])).to.eql(['foo', 'bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!foo', '!bar'])).to.eql(['baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['!*{o,r}', '*'])).to.eql(['foo', 'bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!*{o,r}'])).to.eql(['baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!*{o,r}', '*'])).to.eql(['foo', 'bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!*{o,r}', 'foo'])).to.eql(['baz', 'foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['!*{o,r}', '*', 'foo'])).to.eql(['foo', 'bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!*{o,r}'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!*{o,r}', 'foo'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['!*{o,r}', 'foo'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!*{o,r}'])).to.eql(['baz']);
+		expect(mm(['foo', 'bar', 'baz'], 'foo')).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo'])).to.eql([]);
+		expect(mm(['foo', 'bar', 'baz'], ['*', '!foo'])).to.eql(['bar', 'baz']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', 'bar'])).to.eql(['foo', 'bar']);
+		expect(mm(['foo', 'bar', 'baz'], ['foo', '!bar'])).to.eql(['foo']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', 'bar'])).to.eql(['bar']);
+		expect(mm(['foo', 'bar', 'baz'], ['!foo', '!bar'])).to.eql([]);
+		expect(mm(['foo', 'one', 'two', 'four', 'do', 'once', 'only'], ['once', '!o*', 'once'])).to.eql(['once']);
+		expect(mm(['foo', 'one', 'two', 'four', 'do', 'once', 'only'], ['*', '!o*', 'once'])).to.eql(['foo', 'two', 'four', 'do', 'once']);
+	});
+});
+
+/**
+ * Tests from [globule](https://github.com/cowboy/node-globule)
+ */
+describe('globule', function () {
+	it('Should return empty set if a required argument is missing or an empty set.', function () {
+		expect(mm('', 'foo.js')).to.eql([]);
+		expect(mm('*.js', '')).to.eql([]);
+		expect(mm([], 'foo.js')).to.eql([]);
+		expect(mm('*.js', [])).to.eql([]);
+		expect(mm('', ['foo.js'])).to.eql([]);
+		expect(mm(['*.js'], '')).to.eql([]);
+	});
+
+	it('basic matching should match correctly', function () {
+		expect(mm('foo.js', '*.js')).to.eql(['foo.js']);
+		expect(mm(['foo.js'], '*.js')).to.eql(['foo.js']);
+		expect(mm(['foo.js', 'bar.css'], '*.js')).to.eql(['foo.js']);
+		expect(mm('foo.js', ['*.js', '*.css'])).to.eql(['foo.js']);
+		expect(mm(['foo.js'], ['*.js', '*.css'])).to.eql(['foo.js']);
+		expect(mm(['foo.js', 'bar.css'], ['*.js', '*.css'])).to.eql(['foo.js', 'bar.css']);
+	});
+
+	describe('no matches:', function () {
+		it('should fail to match', function () {
+			expect(mm('foo.css', '*.js')).to.eql([]);
+			expect(mm(['foo.css', 'bar.css'], '*.js')).to.eql([]);
+		});
+	});
+
+	describe('unique:', function () {
+		it('should return a uniqued set', function () {
+			expect(mm(['foo.js', 'foo.js'], '*.js')).to.eql(['foo.js']);
+			expect(mm(['foo.js', 'foo.js'], ['*.js', '*.*'])).to.eql(['foo.js']);
+		});
+	});
+
+	describe('exclusion:', function () {
+		it('solitary exclusion should match nothing', function () {
+			expect(mm(['foo.js', 'bar.js'], ['!*.js'])).to.eql([]);
+		});
+		it('exclusion should cancel match', function () {
+			expect(mm(['foo.js', 'bar.js'], ['*.js', '!*.js'])).to.eql([]);
+		});
+		it('partial exclusion should partially cancel match', function () {
+			expect(mm(['foo.js', 'bar.js', 'baz.js'], ['*.js', '!f*.js'])).to.eql(['bar.js', 'baz.js']);
+		});
+		it('inclusion / exclusion order matters', function () {
+			expect(mm(['foo.js', 'bar.js', 'baz.js'], ['*.js', '!*.js', 'b*.js'])).to.eql(['bar.js', 'baz.js']);
+		});
+		it('inclusion / exclusion order matters', function () {
+			expect(mm(['foo.js', 'bar.js', 'baz.js'], ['*.js', '!f*.js', '*.js'])).to.eql(['bar.js', 'baz.js', 'foo.js']);
+		});
+	});
+
+	describe('options.matchBase:', function () {
+		it('should matchBase (minimatch) when specified.', function () {
+			expect(mm(['foo.js', 'bar', 'baz/xyz.js'], '*.js', {matchBase: true})).to.eql(['foo.js', 'baz/xyz.js']);
+		});
+
+		it('should not matchBase (minimatch) by default.', function () {
+			expect(mm(['foo.js', 'bar', 'baz/xyz.js'], '*.js')).to.eql(['foo.js']);
+		});
+	});
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-multimatch.git



More information about the Pkg-javascript-commits mailing list