1 | # matched [![NPM version](https://img.shields.io/npm/v/matched.svg?style=flat)](https://www.npmjs.com/package/matched) [![NPM monthly downloads](https://img.shields.io/npm/dm/matched.svg?style=flat)](https://npmjs.org/package/matched) [![NPM total downloads](https://img.shields.io/npm/dt/matched.svg?style=flat)](https://npmjs.org/package/matched) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/matched.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/matched)
|
2 |
|
3 | > Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules.
|
4 |
|
5 | Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
|
6 |
|
7 | ## Install
|
8 |
|
9 | Install with [npm](https://www.npmjs.com/):
|
10 |
|
11 | ```sh
|
12 | $ npm install --save matched
|
13 | ```
|
14 |
|
15 | ## Usage
|
16 |
|
17 | ```js
|
18 | const glob = require('matched');
|
19 | // async signature
|
20 | glob(patterns[, options]);
|
21 |
|
22 | // sync signature
|
23 | glob.sync(patterns[, options]);
|
24 | ```
|
25 |
|
26 | * `patterns` (string|array) - one or more glob patterns
|
27 | * `options` - options to pass to [node-glob](https://github.com/isaacs/node-glob);
|
28 |
|
29 | _Also note that if non-glob file paths are passed, only paths that exist on the file system will be returned._
|
30 |
|
31 | **promise**
|
32 |
|
33 | ```js
|
34 | glob(['*.txt'])
|
35 | .then(files => console.log(files)) //=> ['a.txt', 'b.txt', 'c.txt']
|
36 | .catch(console.error)
|
37 |
|
38 | // or with async-await
|
39 | (async() => {
|
40 | let files = await glob('*.txt');
|
41 | console.log(files);
|
42 | //=> ['foo.txt', 'bar.txt']
|
43 | })();
|
44 | ```
|
45 |
|
46 | **callback**
|
47 |
|
48 | ```js
|
49 | glob(['*.js'], (err, files) => {
|
50 | console.log(files);
|
51 | //=> ['utils.js', 'index.js']
|
52 | });
|
53 | ```
|
54 |
|
55 | **sync**
|
56 |
|
57 | ```js
|
58 | let files = glob.sync(['*.js']);
|
59 | //=> ['utils.js', 'index.js']
|
60 | ```
|
61 |
|
62 | **options**
|
63 |
|
64 | All methods take an options object to be forwarded to [node-glob](https://github.com/isaacs/node-glob) as the second argument.
|
65 |
|
66 | ```js
|
67 | const glob = glob(['*.js'], { cwd: 'test' });
|
68 | //=> ['test.js']
|
69 | ```
|
70 |
|
71 | ## v3.0
|
72 |
|
73 | * Removes `cache` property from results array.
|
74 | * Optimizations
|
75 |
|
76 | ## v0.4.1
|
77 |
|
78 | * Exposes a non-enumerable `cache` property on the returned files array. This is a patch release since the property does not change the existing API and should not otherwise effect behavior or results.
|
79 |
|
80 | ## About
|
81 |
|
82 | <details>
|
83 | <summary><strong>Contributing</strong></summary>
|
84 |
|
85 | Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
86 |
|
87 | </details>
|
88 |
|
89 | <details>
|
90 | <summary><strong>Running Tests</strong></summary>
|
91 |
|
92 | Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
|
93 |
|
94 | ```sh
|
95 | $ npm install && npm test
|
96 | ```
|
97 |
|
98 | </details>
|
99 |
|
100 | <details>
|
101 | <summary><strong>Building docs</strong></summary>
|
102 |
|
103 | _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
|
104 |
|
105 | To generate the readme, run the following command:
|
106 |
|
107 | ```sh
|
108 | $ npm install -g verbose/verb#dev verb-generate-readme && verb
|
109 | ```
|
110 |
|
111 | </details>
|
112 |
|
113 | ### Related projects
|
114 |
|
115 | You might also be interested in these projects:
|
116 |
|
117 | * [findup-sync](https://www.npmjs.com/package/findup-sync): Find the first file matching a given pattern in the current directory or the nearest… [more](https://github.com/js-cli/node-findup-sync#readme) | [homepage](https://github.com/js-cli/node-findup-sync#readme "Find the first file matching a given pattern in the current directory or the nearest ancestor directory.")
|
118 | * [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
|
119 | * [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.")
|
120 |
|
121 | ### Contributors
|
122 |
|
123 | | **Commits** | **Contributor** |
|
124 | | --- | --- |
|
125 | | 62 | [jonschlinkert](https://github.com/jonschlinkert) |
|
126 | | 8 | [TrySound](https://github.com/TrySound) |
|
127 | | 1 | [sindresorhus](https://github.com/sindresorhus) |
|
128 |
|
129 | ### Author
|
130 |
|
131 | **Jon Schlinkert**
|
132 |
|
133 | * [GitHub Profile](https://github.com/jonschlinkert)
|
134 | * [Twitter Profile](https://twitter.com/jonschlinkert)
|
135 | * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
136 |
|
137 | ### License
|
138 |
|
139 | Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
|
140 | Released under the [MIT License](LICENSE).
|
141 |
|
142 | ***
|
143 |
|
144 | _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 27, 2018._ |
\ | No newline at end of file |