jass-vue 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +43 -0
  4. data/lib/jass/vue.rb +12 -0
  5. data/lib/jass/vue/version.rb +5 -0
  6. data/vendor/node_modules/arr-diff/index.js +58 -0
  7. data/vendor/node_modules/arr-diff/package.json +49 -0
  8. data/vendor/node_modules/arr-flatten/index.js +22 -0
  9. data/vendor/node_modules/arr-flatten/package.json +76 -0
  10. data/vendor/node_modules/array-unique/index.js +28 -0
  11. data/vendor/node_modules/array-unique/package.json +37 -0
  12. data/vendor/node_modules/braces/index.js +399 -0
  13. data/vendor/node_modules/braces/package.json +83 -0
  14. data/vendor/node_modules/de-indent/index.js +45 -0
  15. data/vendor/node_modules/de-indent/package.json +25 -0
  16. data/vendor/node_modules/de-indent/test.js +30 -0
  17. data/vendor/node_modules/estree-walker/dist/estree-walker.es.js +55 -0
  18. data/vendor/node_modules/estree-walker/dist/estree-walker.es6.js +59 -0
  19. data/vendor/node_modules/estree-walker/dist/estree-walker.umd.js +65 -0
  20. data/vendor/node_modules/estree-walker/package.json +33 -0
  21. data/vendor/node_modules/estree-walker/src/estree-walker.js +49 -0
  22. data/vendor/node_modules/expand-brackets/index.js +163 -0
  23. data/vendor/node_modules/expand-brackets/package.json +62 -0
  24. data/vendor/node_modules/expand-range/index.js +43 -0
  25. data/vendor/node_modules/expand-range/package.json +73 -0
  26. data/vendor/node_modules/extglob/index.js +178 -0
  27. data/vendor/node_modules/extglob/package.json +60 -0
  28. data/vendor/node_modules/filename-regex/index.js +10 -0
  29. data/vendor/node_modules/filename-regex/package.json +50 -0
  30. data/vendor/node_modules/fill-range/index.js +408 -0
  31. data/vendor/node_modules/fill-range/package.json +61 -0
  32. data/vendor/node_modules/for-in/index.js +16 -0
  33. data/vendor/node_modules/for-in/package.json +68 -0
  34. data/vendor/node_modules/for-own/index.js +19 -0
  35. data/vendor/node_modules/for-own/package.json +70 -0
  36. data/vendor/node_modules/glob-base/index.js +51 -0
  37. data/vendor/node_modules/glob-base/package.json +52 -0
  38. data/vendor/node_modules/glob-parent/index.js +10 -0
  39. data/vendor/node_modules/glob-parent/package.json +35 -0
  40. data/vendor/node_modules/glob-parent/test.js +28 -0
  41. data/vendor/node_modules/he/bin/he +148 -0
  42. data/vendor/node_modules/he/he.js +342 -0
  43. data/vendor/node_modules/he/man/he.1 +78 -0
  44. data/vendor/node_modules/he/package.json +56 -0
  45. data/vendor/node_modules/is-buffer/index.js +21 -0
  46. data/vendor/node_modules/is-buffer/package.json +51 -0
  47. data/vendor/node_modules/is-dotfile/index.js +14 -0
  48. data/vendor/node_modules/is-dotfile/package.json +69 -0
  49. data/vendor/node_modules/is-equal-shallow/index.js +27 -0
  50. data/vendor/node_modules/is-equal-shallow/package.json +54 -0
  51. data/vendor/node_modules/is-extendable/index.js +13 -0
  52. data/vendor/node_modules/is-extendable/package.json +51 -0
  53. data/vendor/node_modules/is-extglob/index.js +11 -0
  54. data/vendor/node_modules/is-extglob/package.json +48 -0
  55. data/vendor/node_modules/is-glob/index.js +14 -0
  56. data/vendor/node_modules/is-glob/package.json +60 -0
  57. data/vendor/node_modules/is-number/index.js +19 -0
  58. data/vendor/node_modules/is-number/package.json +59 -0
  59. data/vendor/node_modules/is-posix-bracket/index.js +10 -0
  60. data/vendor/node_modules/is-posix-bracket/package.json +64 -0
  61. data/vendor/node_modules/is-primitive/index.js +13 -0
  62. data/vendor/node_modules/is-primitive/package.json +46 -0
  63. data/vendor/node_modules/isarray/index.js +5 -0
  64. data/vendor/node_modules/isarray/package.json +45 -0
  65. data/vendor/node_modules/isarray/test.js +20 -0
  66. data/vendor/node_modules/isobject/index.js +14 -0
  67. data/vendor/node_modules/isobject/package.json +67 -0
  68. data/vendor/node_modules/kind-of/index.js +116 -0
  69. data/vendor/node_modules/kind-of/package.json +90 -0
  70. data/vendor/node_modules/magic-string/dist/magic-string.cjs.js +1287 -0
  71. data/vendor/node_modules/magic-string/dist/magic-string.es.js +1283 -0
  72. data/vendor/node_modules/magic-string/dist/magic-string.umd.js +1339 -0
  73. data/vendor/node_modules/magic-string/package.json +60 -0
  74. data/vendor/node_modules/magic-string/src/Bundle.js +263 -0
  75. data/vendor/node_modules/magic-string/src/Chunk.js +154 -0
  76. data/vendor/node_modules/magic-string/src/MagicString.js +618 -0
  77. data/vendor/node_modules/magic-string/src/index-legacy.js +6 -0
  78. data/vendor/node_modules/magic-string/src/index.js +4 -0
  79. data/vendor/node_modules/magic-string/src/utils/Mappings.js +117 -0
  80. data/vendor/node_modules/magic-string/src/utils/SourceMap.js +21 -0
  81. data/vendor/node_modules/magic-string/src/utils/Stats.js +18 -0
  82. data/vendor/node_modules/magic-string/src/utils/btoa.js +13 -0
  83. data/vendor/node_modules/magic-string/src/utils/getLocator.js +35 -0
  84. data/vendor/node_modules/magic-string/src/utils/getRelativePath.js +18 -0
  85. data/vendor/node_modules/magic-string/src/utils/guessIndent.js +25 -0
  86. data/vendor/node_modules/magic-string/src/utils/hasOwnProp.js +1 -0
  87. data/vendor/node_modules/magic-string/src/utils/isObject.js +5 -0
  88. data/vendor/node_modules/micromatch/index.js +431 -0
  89. data/vendor/node_modules/micromatch/lib/chars.js +67 -0
  90. data/vendor/node_modules/micromatch/lib/expand.js +304 -0
  91. data/vendor/node_modules/micromatch/lib/glob.js +193 -0
  92. data/vendor/node_modules/micromatch/lib/utils.js +149 -0
  93. data/vendor/node_modules/micromatch/package.json +114 -0
  94. data/vendor/node_modules/normalize-path/index.js +19 -0
  95. data/vendor/node_modules/normalize-path/package.json +78 -0
  96. data/vendor/node_modules/object.omit/index.js +40 -0
  97. data/vendor/node_modules/object.omit/package.json +67 -0
  98. data/vendor/node_modules/parse-glob/index.js +156 -0
  99. data/vendor/node_modules/parse-glob/package.json +62 -0
  100. data/vendor/node_modules/preserve/index.js +54 -0
  101. data/vendor/node_modules/preserve/package.json +48 -0
  102. data/vendor/node_modules/preserve/test.js +48 -0
  103. data/vendor/node_modules/randomatic/index.js +82 -0
  104. data/vendor/node_modules/randomatic/node_modules/is-number/index.js +22 -0
  105. data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/index.js +116 -0
  106. data/vendor/node_modules/randomatic/node_modules/is-number/node_modules/kind-of/package.json +90 -0
  107. data/vendor/node_modules/randomatic/node_modules/is-number/package.json +83 -0
  108. data/vendor/node_modules/randomatic/node_modules/kind-of/index.js +119 -0
  109. data/vendor/node_modules/randomatic/node_modules/kind-of/package.json +90 -0
  110. data/vendor/node_modules/randomatic/package.json +78 -0
  111. data/vendor/node_modules/regex-cache/index.js +68 -0
  112. data/vendor/node_modules/regex-cache/package.json +64 -0
  113. data/vendor/node_modules/remove-trailing-separator/index.js +17 -0
  114. data/vendor/node_modules/remove-trailing-separator/package.json +37 -0
  115. data/vendor/node_modules/repeat-element/index.js +18 -0
  116. data/vendor/node_modules/repeat-element/package.json +44 -0
  117. data/vendor/node_modules/repeat-string/index.js +70 -0
  118. data/vendor/node_modules/repeat-string/package.json +77 -0
  119. data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.common.js +164 -0
  120. data/vendor/node_modules/rollup-plugin-vue2/dist/rollup-plugin-vue2.es.js +160 -0
  121. data/vendor/node_modules/rollup-plugin-vue2/package.json +50 -0
  122. data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.cjs.js +223 -0
  123. data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es.js +214 -0
  124. data/vendor/node_modules/rollup-pluginutils/dist/pluginutils.es6.js +217 -0
  125. data/vendor/node_modules/rollup-pluginutils/package.json +40 -0
  126. data/vendor/node_modules/rollup-pluginutils/src/addExtension.js +6 -0
  127. data/vendor/node_modules/rollup-pluginutils/src/attachScopes.js +147 -0
  128. data/vendor/node_modules/rollup-pluginutils/src/createFilter.js +33 -0
  129. data/vendor/node_modules/rollup-pluginutils/src/index.js +4 -0
  130. data/vendor/node_modules/rollup-pluginutils/src/makeLegalIdentifier.js +15 -0
  131. data/vendor/node_modules/rollup-pluginutils/src/utils/ensureArray.js +5 -0
  132. data/vendor/node_modules/vlq/dist/vlq.js +91 -0
  133. data/vendor/node_modules/vlq/package.json +27 -0
  134. data/vendor/node_modules/vlq/src/vlq.js +78 -0
  135. data/vendor/node_modules/vue-template-compiler/browser.js +5237 -0
  136. data/vendor/node_modules/vue-template-compiler/build.js +4835 -0
  137. data/vendor/node_modules/vue-template-compiler/index.js +18 -0
  138. data/vendor/node_modules/vue-template-compiler/package.json +27 -0
  139. data/vendor/node_modules/vue-template-es2015-compiler/buble.js +14112 -0
  140. data/vendor/node_modules/vue-template-es2015-compiler/index.js +24 -0
  141. data/vendor/node_modules/vue-template-es2015-compiler/package.json +28 -0
  142. data/vendor/package.json +9 -0
  143. data/vendor/yarn.lock +268 -0
  144. metadata +242 -0
@@ -0,0 +1,6 @@
1
+ import MagicString from './MagicString.js';
2
+ import Bundle from './Bundle.js';
3
+
4
+ MagicString.Bundle = Bundle;
5
+
6
+ export default MagicString;
@@ -0,0 +1,4 @@
1
+ import MagicString from './MagicString.js';
2
+
3
+ export default MagicString;
4
+ export { default as Bundle } from './Bundle.js';
@@ -0,0 +1,117 @@
1
+ import { encode } from 'vlq';
2
+
3
+ export default function Mappings ( hires ) {
4
+ const offsets = {
5
+ generatedCodeColumn: 0,
6
+ sourceIndex: 0,
7
+ sourceCodeLine: 0,
8
+ sourceCodeColumn: 0,
9
+ sourceCodeName: 0
10
+ };
11
+
12
+ let generatedCodeLine = 0;
13
+ let generatedCodeColumn = 0;
14
+
15
+ this.raw = [];
16
+ let rawSegments = this.raw[ generatedCodeLine ] = [];
17
+
18
+ let pending = null;
19
+
20
+ this.addEdit = ( sourceIndex, content, original, loc, nameIndex ) => {
21
+ if ( content.length ) {
22
+ rawSegments.push([
23
+ generatedCodeColumn,
24
+ sourceIndex,
25
+ loc.line,
26
+ loc.column,
27
+ nameIndex,
28
+ ]);
29
+ } else if ( pending ) {
30
+ rawSegments.push( pending );
31
+ }
32
+
33
+ this.advance( content );
34
+ pending = null;
35
+ };
36
+
37
+ this.addUneditedChunk = ( sourceIndex, chunk, original, loc, sourcemapLocations ) => {
38
+ let originalCharIndex = chunk.start;
39
+ let first = true;
40
+
41
+ while ( originalCharIndex < chunk.end ) {
42
+ if ( hires || first || sourcemapLocations[ originalCharIndex ] ) {
43
+ rawSegments.push([
44
+ generatedCodeColumn,
45
+ sourceIndex,
46
+ loc.line,
47
+ loc.column,
48
+ -1
49
+ ]);
50
+ }
51
+
52
+ if ( original[ originalCharIndex ] === '\n' ) {
53
+ loc.line += 1;
54
+ loc.column = 0;
55
+ generatedCodeLine += 1;
56
+ this.raw[ generatedCodeLine ] = rawSegments = [];
57
+ generatedCodeColumn = 0;
58
+ } else {
59
+ loc.column += 1;
60
+ generatedCodeColumn += 1;
61
+ }
62
+
63
+ originalCharIndex += 1;
64
+ first = false;
65
+ }
66
+
67
+ pending = [
68
+ generatedCodeColumn,
69
+ sourceIndex,
70
+ loc.line,
71
+ loc.column,
72
+ -1,
73
+ ];
74
+ };
75
+
76
+ this.advance = str => {
77
+ if ( !str ) return;
78
+
79
+ const lines = str.split( '\n' );
80
+ const lastLine = lines.pop();
81
+
82
+ if ( lines.length ) {
83
+ generatedCodeLine += lines.length;
84
+ this.raw[ generatedCodeLine ] = rawSegments = [];
85
+ generatedCodeColumn = lastLine.length;
86
+ } else {
87
+ generatedCodeColumn += lastLine.length;
88
+ }
89
+ };
90
+
91
+ this.encode = () => {
92
+ return this.raw.map( segments => {
93
+ let generatedCodeColumn = 0;
94
+
95
+ return segments.map( segment => {
96
+ const arr = [
97
+ segment[0] - generatedCodeColumn,
98
+ segment[1] - offsets.sourceIndex,
99
+ segment[2] - offsets.sourceCodeLine,
100
+ segment[3] - offsets.sourceCodeColumn
101
+ ];
102
+
103
+ generatedCodeColumn = segment[0];
104
+ offsets.sourceIndex = segment[1];
105
+ offsets.sourceCodeLine = segment[2];
106
+ offsets.sourceCodeColumn = segment[3];
107
+
108
+ if ( ~segment[4] ) {
109
+ arr.push( segment[4] - offsets.sourceCodeName );
110
+ offsets.sourceCodeName = segment[4];
111
+ }
112
+
113
+ return encode( arr );
114
+ }).join( ',' );
115
+ }).join( ';' );
116
+ };
117
+ }
@@ -0,0 +1,21 @@
1
+ import btoa from './btoa.js';
2
+
3
+ export default function SourceMap ( properties ) {
4
+ this.version = 3;
5
+
6
+ this.file = properties.file;
7
+ this.sources = properties.sources;
8
+ this.sourcesContent = properties.sourcesContent;
9
+ this.names = properties.names;
10
+ this.mappings = properties.mappings;
11
+ }
12
+
13
+ SourceMap.prototype = {
14
+ toString () {
15
+ return JSON.stringify( this );
16
+ },
17
+
18
+ toUrl () {
19
+ return 'data:application/json;charset=utf-8;base64,' + btoa( this.toString() );
20
+ }
21
+ };
@@ -0,0 +1,18 @@
1
+ export default class Stats {
2
+ constructor () {
3
+ Object.defineProperties( this, {
4
+ startTimes: { value: {} }
5
+ });
6
+ }
7
+
8
+ time ( label ) {
9
+ this.startTimes[ label ] = process.hrtime();
10
+ }
11
+
12
+ timeEnd ( label ) {
13
+ const elapsed = process.hrtime( this.startTimes[ label ] );
14
+
15
+ if ( !this[ label ] ) this[ label ] = 0;
16
+ this[ label ] += elapsed[0] * 1e3 + elapsed[1] * 1e-6;
17
+ }
18
+ }
@@ -0,0 +1,13 @@
1
+ let _btoa;
2
+
3
+ if ( typeof window !== 'undefined' && typeof window.btoa === 'function' ) {
4
+ _btoa = window.btoa;
5
+ } else if ( typeof Buffer === 'function' ) {
6
+ _btoa = str => new Buffer( str ).toString( 'base64' );
7
+ } else {
8
+ _btoa = () => {
9
+ throw new Error( 'Unsupported environment: `window.btoa` or `Buffer` should be supported.' );
10
+ };
11
+ }
12
+
13
+ export default _btoa;
@@ -0,0 +1,35 @@
1
+ export default function getLocator ( source ) {
2
+ const originalLines = source.split( '\n' );
3
+
4
+ let start = 0;
5
+ const lineRanges = originalLines.map( ( line, i ) => {
6
+ const end = start + line.length + 1;
7
+ const range = { start, end, line: i };
8
+
9
+ start = end;
10
+ return range;
11
+ });
12
+
13
+ let i = 0;
14
+
15
+ function rangeContains ( range, index ) {
16
+ return range.start <= index && index < range.end;
17
+ }
18
+
19
+ function getLocation ( range, index ) {
20
+ return { line: range.line, column: index - range.start };
21
+ }
22
+
23
+ return function locate ( index ) {
24
+ let range = lineRanges[i];
25
+
26
+ const d = index >= range.end ? 1 : -1;
27
+
28
+ while ( range ) {
29
+ if ( rangeContains( range, index ) ) return getLocation( range, index );
30
+
31
+ i += d;
32
+ range = lineRanges[i];
33
+ }
34
+ };
35
+ }
@@ -0,0 +1,18 @@
1
+ export default function getRelativePath ( from, to ) {
2
+ const fromParts = from.split( /[\/\\]/ );
3
+ const toParts = to.split( /[\/\\]/ );
4
+
5
+ fromParts.pop(); // get dirname
6
+
7
+ while ( fromParts[0] === toParts[0] ) {
8
+ fromParts.shift();
9
+ toParts.shift();
10
+ }
11
+
12
+ if ( fromParts.length ) {
13
+ let i = fromParts.length;
14
+ while ( i-- ) fromParts[i] = '..';
15
+ }
16
+
17
+ return fromParts.concat( toParts ).join( '/' );
18
+ }
@@ -0,0 +1,25 @@
1
+ export default function guessIndent ( code ) {
2
+ const lines = code.split( '\n' );
3
+
4
+ const tabbed = lines.filter( line => /^\t+/.test( line ) );
5
+ const spaced = lines.filter( line => /^ {2,}/.test( line ) );
6
+
7
+ if ( tabbed.length === 0 && spaced.length === 0 ) {
8
+ return null;
9
+ }
10
+
11
+ // More lines tabbed than spaced? Assume tabs, and
12
+ // default to tabs in the case of a tie (or nothing
13
+ // to go on)
14
+ if ( tabbed.length >= spaced.length ) {
15
+ return '\t';
16
+ }
17
+
18
+ // Otherwise, we need to guess the multiple
19
+ const min = spaced.reduce( ( previous, current ) => {
20
+ const numSpaces = /^ +/.exec( current )[0].length;
21
+ return Math.min( numSpaces, previous );
22
+ }, Infinity );
23
+
24
+ return new Array( min + 1 ).join( ' ' );
25
+ }
@@ -0,0 +1 @@
1
+ export default Object.prototype.hasOwnProperty;
@@ -0,0 +1,5 @@
1
+ const toString = Object.prototype.toString;
2
+
3
+ export default function isObject ( thing ) {
4
+ return toString.call( thing ) === '[object Object]';
5
+ }
@@ -0,0 +1,431 @@
1
+ /*!
2
+ * micromatch <https://github.com/jonschlinkert/micromatch>
3
+ *
4
+ * Copyright (c) 2014-2015, Jon Schlinkert.
5
+ * Licensed under the MIT License.
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var expand = require('./lib/expand');
11
+ var utils = require('./lib/utils');
12
+
13
+ /**
14
+ * The main function. Pass an array of filepaths,
15
+ * and a string or array of glob patterns
16
+ *
17
+ * @param {Array|String} `files`
18
+ * @param {Array|String} `patterns`
19
+ * @param {Object} `opts`
20
+ * @return {Array} Array of matches
21
+ */
22
+
23
+ function micromatch(files, patterns, opts) {
24
+ if (!files || !patterns) return [];
25
+ opts = opts || {};
26
+
27
+ if (typeof opts.cache === 'undefined') {
28
+ opts.cache = true;
29
+ }
30
+
31
+ if (!Array.isArray(patterns)) {
32
+ return match(files, patterns, opts);
33
+ }
34
+
35
+ var len = patterns.length, i = 0;
36
+ var omit = [], keep = [];
37
+
38
+ while (len--) {
39
+ var glob = patterns[i++];
40
+ if (typeof glob === 'string' && glob.charCodeAt(0) === 33 /* ! */) {
41
+ omit.push.apply(omit, match(files, glob.slice(1), opts));
42
+ } else {
43
+ keep.push.apply(keep, match(files, glob, opts));
44
+ }
45
+ }
46
+ return utils.diff(keep, omit);
47
+ }
48
+
49
+ /**
50
+ * Return an array of files that match the given glob pattern.
51
+ *
52
+ * This function is called by the main `micromatch` function If you only
53
+ * need to pass a single pattern you might get very minor speed improvements
54
+ * using this function.
55
+ *
56
+ * @param {Array} `files`
57
+ * @param {String} `pattern`
58
+ * @param {Object} `options`
59
+ * @return {Array}
60
+ */
61
+
62
+ function match(files, pattern, opts) {
63
+ if (utils.typeOf(files) !== 'string' && !Array.isArray(files)) {
64
+ throw new Error(msg('match', 'files', 'a string or array'));
65
+ }
66
+
67
+ files = utils.arrayify(files);
68
+ opts = opts || {};
69
+
70
+ var negate = opts.negate || false;
71
+ var orig = pattern;
72
+
73
+ if (typeof pattern === 'string') {
74
+ negate = pattern.charAt(0) === '!';
75
+ if (negate) {
76
+ pattern = pattern.slice(1);
77
+ }
78
+
79
+ // we need to remove the character regardless,
80
+ // so the above logic is still needed
81
+ if (opts.nonegate === true) {
82
+ negate = false;
83
+ }
84
+ }
85
+
86
+ var _isMatch = matcher(pattern, opts);
87
+ var len = files.length, i = 0;
88
+ var res = [];
89
+
90
+ while (i < len) {
91
+ var file = files[i++];
92
+ var fp = utils.unixify(file, opts);
93
+
94
+ if (!_isMatch(fp)) { continue; }
95
+ res.push(fp);
96
+ }
97
+
98
+ if (res.length === 0) {
99
+ if (opts.failglob === true) {
100
+ throw new Error('micromatch.match() found no matches for: "' + orig + '".');
101
+ }
102
+
103
+ if (opts.nonull || opts.nullglob) {
104
+ res.push(utils.unescapeGlob(orig));
105
+ }
106
+ }
107
+
108
+ // if `negate` was defined, diff negated files
109
+ if (negate) { res = utils.diff(files, res); }
110
+
111
+ // if `ignore` was defined, diff ignored filed
112
+ if (opts.ignore && opts.ignore.length) {
113
+ pattern = opts.ignore;
114
+ opts = utils.omit(opts, ['ignore']);
115
+ res = utils.diff(res, micromatch(res, pattern, opts));
116
+ }
117
+
118
+ if (opts.nodupes) {
119
+ return utils.unique(res);
120
+ }
121
+ return res;
122
+ }
123
+
124
+ /**
125
+ * Returns a function that takes a glob pattern or array of glob patterns
126
+ * to be used with `Array#filter()`. (Internally this function generates
127
+ * the matching function using the [matcher] method).
128
+ *
129
+ * ```js
130
+ * var fn = mm.filter('[a-c]');
131
+ * ['a', 'b', 'c', 'd', 'e'].filter(fn);
132
+ * //=> ['a', 'b', 'c']
133
+ * ```
134
+ * @param {String|Array} `patterns` Can be a glob or array of globs.
135
+ * @param {Options} `opts` Options to pass to the [matcher] method.
136
+ * @return {Function} Filter function to be passed to `Array#filter()`.
137
+ */
138
+
139
+ function filter(patterns, opts) {
140
+ if (!Array.isArray(patterns) && typeof patterns !== 'string') {
141
+ throw new TypeError(msg('filter', 'patterns', 'a string or array'));
142
+ }
143
+
144
+ patterns = utils.arrayify(patterns);
145
+ var len = patterns.length, i = 0;
146
+ var patternMatchers = Array(len);
147
+ while (i < len) {
148
+ patternMatchers[i] = matcher(patterns[i++], opts);
149
+ }
150
+
151
+ return function(fp) {
152
+ if (fp == null) return [];
153
+ var len = patternMatchers.length, i = 0;
154
+ var res = true;
155
+
156
+ fp = utils.unixify(fp, opts);
157
+ while (i < len) {
158
+ var fn = patternMatchers[i++];
159
+ if (!fn(fp)) {
160
+ res = false;
161
+ break;
162
+ }
163
+ }
164
+ return res;
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Returns true if the filepath contains the given
170
+ * pattern. Can also return a function for matching.
171
+ *
172
+ * ```js
173
+ * isMatch('foo.md', '*.md', {});
174
+ * //=> true
175
+ *
176
+ * isMatch('*.md', {})('foo.md')
177
+ * //=> true
178
+ * ```
179
+ * @param {String} `fp`
180
+ * @param {String} `pattern`
181
+ * @param {Object} `opts`
182
+ * @return {Boolean}
183
+ */
184
+
185
+ function isMatch(fp, pattern, opts) {
186
+ if (typeof fp !== 'string') {
187
+ throw new TypeError(msg('isMatch', 'filepath', 'a string'));
188
+ }
189
+
190
+ fp = utils.unixify(fp, opts);
191
+ if (utils.typeOf(pattern) === 'object') {
192
+ return matcher(fp, pattern);
193
+ }
194
+ return matcher(pattern, opts)(fp);
195
+ }
196
+
197
+ /**
198
+ * Returns true if the filepath matches the
199
+ * given pattern.
200
+ */
201
+
202
+ function contains(fp, pattern, opts) {
203
+ if (typeof fp !== 'string') {
204
+ throw new TypeError(msg('contains', 'pattern', 'a string'));
205
+ }
206
+
207
+ opts = opts || {};
208
+ opts.contains = (pattern !== '');
209
+ fp = utils.unixify(fp, opts);
210
+
211
+ if (opts.contains && !utils.isGlob(pattern)) {
212
+ return fp.indexOf(pattern) !== -1;
213
+ }
214
+ return matcher(pattern, opts)(fp);
215
+ }
216
+
217
+ /**
218
+ * Returns true if a file path matches any of the
219
+ * given patterns.
220
+ *
221
+ * @param {String} `fp` The filepath to test.
222
+ * @param {String|Array} `patterns` Glob patterns to use.
223
+ * @param {Object} `opts` Options to pass to the `matcher()` function.
224
+ * @return {String}
225
+ */
226
+
227
+ function any(fp, patterns, opts) {
228
+ if (!Array.isArray(patterns) && typeof patterns !== 'string') {
229
+ throw new TypeError(msg('any', 'patterns', 'a string or array'));
230
+ }
231
+
232
+ patterns = utils.arrayify(patterns);
233
+ var len = patterns.length;
234
+
235
+ fp = utils.unixify(fp, opts);
236
+ while (len--) {
237
+ var isMatch = matcher(patterns[len], opts);
238
+ if (isMatch(fp)) {
239
+ return true;
240
+ }
241
+ }
242
+ return false;
243
+ }
244
+
245
+ /**
246
+ * Filter the keys of an object with the given `glob` pattern
247
+ * and `options`
248
+ *
249
+ * @param {Object} `object`
250
+ * @param {Pattern} `object`
251
+ * @return {Array}
252
+ */
253
+
254
+ function matchKeys(obj, glob, options) {
255
+ if (utils.typeOf(obj) !== 'object') {
256
+ throw new TypeError(msg('matchKeys', 'first argument', 'an object'));
257
+ }
258
+
259
+ var fn = matcher(glob, options);
260
+ var res = {};
261
+
262
+ for (var key in obj) {
263
+ if (obj.hasOwnProperty(key) && fn(key)) {
264
+ res[key] = obj[key];
265
+ }
266
+ }
267
+ return res;
268
+ }
269
+
270
+ /**
271
+ * Return a function for matching based on the
272
+ * given `pattern` and `options`.
273
+ *
274
+ * @param {String} `pattern`
275
+ * @param {Object} `options`
276
+ * @return {Function}
277
+ */
278
+
279
+ function matcher(pattern, opts) {
280
+ // pattern is a function
281
+ if (typeof pattern === 'function') {
282
+ return pattern;
283
+ }
284
+ // pattern is a regex
285
+ if (pattern instanceof RegExp) {
286
+ return function(fp) {
287
+ return pattern.test(fp);
288
+ };
289
+ }
290
+
291
+ if (typeof pattern !== 'string') {
292
+ throw new TypeError(msg('matcher', 'pattern', 'a string, regex, or function'));
293
+ }
294
+
295
+ // strings, all the way down...
296
+ pattern = utils.unixify(pattern, opts);
297
+
298
+ // pattern is a non-glob string
299
+ if (!utils.isGlob(pattern)) {
300
+ return utils.matchPath(pattern, opts);
301
+ }
302
+ // pattern is a glob string
303
+ var re = makeRe(pattern, opts);
304
+
305
+ // `matchBase` is defined
306
+ if (opts && opts.matchBase) {
307
+ return utils.hasFilename(re, opts);
308
+ }
309
+ // `matchBase` is not defined
310
+ return function(fp) {
311
+ fp = utils.unixify(fp, opts);
312
+ return re.test(fp);
313
+ };
314
+ }
315
+
316
+ /**
317
+ * Create and cache a regular expression for matching
318
+ * file paths.
319
+ *
320
+ * If the leading character in the `glob` is `!`, a negation
321
+ * regex is returned.
322
+ *
323
+ * @param {String} `glob`
324
+ * @param {Object} `options`
325
+ * @return {RegExp}
326
+ */
327
+
328
+ function toRegex(glob, options) {
329
+ // clone options to prevent mutating the original object
330
+ var opts = Object.create(options || {});
331
+ var flags = opts.flags || '';
332
+ if (opts.nocase && flags.indexOf('i') === -1) {
333
+ flags += 'i';
334
+ }
335
+
336
+ var parsed = expand(glob, opts);
337
+
338
+ // pass in tokens to avoid parsing more than once
339
+ opts.negated = opts.negated || parsed.negated;
340
+ opts.negate = opts.negated;
341
+ glob = wrapGlob(parsed.pattern, opts);
342
+ var re;
343
+
344
+ try {
345
+ re = new RegExp(glob, flags);
346
+ return re;
347
+ } catch (err) {
348
+ err.reason = 'micromatch invalid regex: (' + re + ')';
349
+ if (opts.strict) throw new SyntaxError(err);
350
+ }
351
+
352
+ // we're only here if a bad pattern was used and the user
353
+ // passed `options.silent`, so match nothing
354
+ return /$^/;
355
+ }
356
+
357
+ /**
358
+ * Create the regex to do the matching. If the leading
359
+ * character in the `glob` is `!` a negation regex is returned.
360
+ *
361
+ * @param {String} `glob`
362
+ * @param {Boolean} `negate`
363
+ */
364
+
365
+ function wrapGlob(glob, opts) {
366
+ var prefix = (opts && !opts.contains) ? '^' : '';
367
+ var after = (opts && !opts.contains) ? '$' : '';
368
+ glob = ('(?:' + glob + ')' + after);
369
+ if (opts && opts.negate) {
370
+ return prefix + ('(?!^' + glob + ').*$');
371
+ }
372
+ return prefix + glob;
373
+ }
374
+
375
+ /**
376
+ * Create and cache a regular expression for matching file paths.
377
+ * If the leading character in the `glob` is `!`, a negation
378
+ * regex is returned.
379
+ *
380
+ * @param {String} `glob`
381
+ * @param {Object} `options`
382
+ * @return {RegExp}
383
+ */
384
+
385
+ function makeRe(glob, opts) {
386
+ if (utils.typeOf(glob) !== 'string') {
387
+ throw new Error(msg('makeRe', 'glob', 'a string'));
388
+ }
389
+ return utils.cache(toRegex, glob, opts);
390
+ }
391
+
392
+ /**
393
+ * Make error messages consistent. Follows this format:
394
+ *
395
+ * ```js
396
+ * msg(methodName, argNumber, nativeType);
397
+ * // example:
398
+ * msg('matchKeys', 'first', 'an object');
399
+ * ```
400
+ *
401
+ * @param {String} `method`
402
+ * @param {String} `num`
403
+ * @param {String} `type`
404
+ * @return {String}
405
+ */
406
+
407
+ function msg(method, what, type) {
408
+ return 'micromatch.' + method + '(): ' + what + ' should be ' + type + '.';
409
+ }
410
+
411
+ /**
412
+ * Public methods
413
+ */
414
+
415
+ /* eslint no-multi-spaces: 0 */
416
+ micromatch.any = any;
417
+ micromatch.braces = micromatch.braceExpand = utils.braces;
418
+ micromatch.contains = contains;
419
+ micromatch.expand = expand;
420
+ micromatch.filter = filter;
421
+ micromatch.isMatch = isMatch;
422
+ micromatch.makeRe = makeRe;
423
+ micromatch.match = match;
424
+ micromatch.matcher = matcher;
425
+ micromatch.matchKeys = matchKeys;
426
+
427
+ /**
428
+ * Expose `micromatch`
429
+ */
430
+
431
+ module.exports = micromatch;