Skip to content

Commit 4c82136

Browse files
committed
chore(glob-cache): format
Signed-off-by: Charlike Mike Reagent <[email protected]>
1 parent 90f1e4e commit 4c82136

File tree

2 files changed

+99
-83
lines changed

2 files changed

+99
-83
lines changed

@packages/glob-cache/README.md

Lines changed: 62 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
# glob-cache [![npm version][npmv-img]][npmv-url] [![License][license-img]][license-url] [![Libera Manifesto][libera-manifesto-img]][libera-manifesto-url]
99

10-
> Best and fastest file globbing solution for Node.js - can use **any** glob library like `glob`, `globby` or `fast-glob`! Streaming, Promise and Hook APIs, with built in caching layer using `cacache`. Makes you Instant Fast™.
10+
> Best and fastest file globbing solution for Node.js - can use **any** glob
11+
> library like `glob`, `globby` or `fast-glob`! Streaming, Promise and Hook
12+
> APIs, with built in caching layer using `cacache`. Makes you Instant Fast™.
1113
1214
Please consider following this project's author,
1315
[Charlike Mike Reagent](https://github.com/tunnckoCore), and :star: the project
@@ -67,31 +69,31 @@ from [GitHub Actions](https://github.com/features/actions) with
6769

6870
- [Install](#install)
6971
- [API](#api)
70-
* [globCache](#globcache)
71-
+ [Signature](#signature)
72-
+ [Params](#params)
73-
+ [Examples](#examples)
74-
* [globCache.stream](#globcachestream)
75-
+ [Signature](#signature-1)
76-
+ [Params](#params-1)
77-
+ [Examples](#examples-1)
78-
* [globCache.promise](#globcachepromise)
79-
+ [Signature](#signature-2)
80-
+ [Params](#params-2)
81-
+ [Examples](#examples-2)
72+
- [globCache](#globcache)
73+
- [Signature](#signature)
74+
- [Params](#params)
75+
- [Examples](#examples)
76+
- [globCache.stream](#globcachestream)
77+
- [Signature](#signature-1)
78+
- [Params](#params-1)
79+
- [Examples](#examples-1)
80+
- [globCache.promise](#globcachepromise)
81+
- [Signature](#signature-2)
82+
- [Params](#params-2)
83+
- [Examples](#examples-2)
8284
- [Context and how it works](#context-and-how-it-works)
8385
- [Contributing](#contributing)
84-
* [Guides and Community](#guides-and-community)
85-
* [Support the project](#support-the-project)
86+
- [Guides and Community](#guides-and-community)
87+
- [Support the project](#support-the-project)
8688
- [Contributors](#contributors)
8789
- [License](#license)
8890

89-
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
91+
_(TOC generated by [verb](https://github.com/verbose/verb) using
92+
[markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
9093

9194
## Install
9295

93-
This project requires [**Node.js**](https://nodejs.org) **>=10.18**
94-
_(see
96+
This project requires [**Node.js**](https://nodejs.org) **>=10.18** _(see
9597
[Support & Release Policy](https://github.com/tunnckoCoreLabs/support-release-policy))_.
9698
Install it using [**yarn**](https://yarnpkg.com) or
9799
[**npm**](https://npmjs.com).<br> _We highly recommend to use Yarn when you
@@ -109,9 +111,9 @@ _Generated using [jest-runner-docs](https://ghub.now.sh/jest-runner-docs)._
109111

110112
### [globCache](./src/index.js#L40)
111113

112-
A mirror of `globCache.stream` and so an "async generator" function,
113-
returning an AsyncIterable. This mirror exists because it's
114-
a common practice to have a `(globPatterns, options)` signature.
114+
A mirror of `globCache.stream` and so an "async generator" function, returning
115+
an AsyncIterable. This mirror exists because it's a common practice to have a
116+
`(globPatterns, options)` signature.
115117

116118
<span id="globcache-signature"></span>
117119

@@ -136,24 +138,25 @@ function(patterns, options)
136138
const globCache = require('glob-cache');
137139
138140
const iterable = globCache(['src/*.js', 'test/*.{js,ts}'], {
139-
cwd: './foo/bar'
141+
cwd: './foo/bar',
140142
});
141143
142144
// equivalent to
143145
144146
const iter = globCache.stream({
145147
include: ['src/*.js', 'test/*.{js,ts}'],
146-
cwd: './foo/bar'
148+
cwd: './foo/bar',
147149
});
148150
```
149151

150152
### [globCache.stream](./src/index.js#L84)
151153

152-
Match files and folders with glob patterns, by default using [fast-glob's `.stream()`](https://ghub.now.sh/fast-glob).
153-
This function is [async generator](https://javascript.info/async-iterators-generators)
154-
and returns "async iterable", so you can use the `for await ... of` loop. Note that this loop
155-
should be used inside an `async function`.
156-
Each item is a [Context](#context-and-how-it-works) object, which is also passed to each hook.
154+
Match files and folders with glob patterns, by default using
155+
[fast-glob's `.stream()`](https://ghub.now.sh/fast-glob). This function is
156+
[async generator](https://javascript.info/async-iterators-generators) and
157+
returns "async iterable", so you can use the `for await ... of` loop. Note that
158+
this loop should be used inside an `async function`. Each item is a
159+
[Context](#context-and-how-it-works) object, which is also passed to each hook.
157160

158161
<span id="globcache.stream-signature"></span>
159162

@@ -170,17 +173,25 @@ function(options)
170173
- `options.cwd` **{string}** - working directory, defaults to `process.cwd()`
171174
- `options.include` **{string|Array}** - string or array of string glob patterns
172175
- `options.patterns` **{string|Array}** - alias of `options.include`
173-
- `options.exclude` **{string|Array}** - ignore glob patterns, passed to `options.globOptions.ignore`
176+
- `options.exclude` **{string|Array}** - ignore glob patterns, passed to
177+
`options.globOptions.ignore`
174178
- `options.ignore` **{string|Array}** - alias of `options.exclude`
175-
- `options.hooks` **{object}** - an object with hooks functions, each hook passed with [Context](#context-and-how-it-works)
179+
- `options.hooks` **{object}** - an object with hooks functions, each hook
180+
passed with [Context](#context-and-how-it-works)
176181
- `options.hooks.found` **{Function}** - called when a cache for a file is found
177-
- `options.hooks.notFound` **{Function}** - called when file is not found in cache (usually the first hit)
178-
- `options.hooks.changed` **{Function}** - called always when source file differs the cache file
179-
- `options.hooks.notChanged` **{Function}** - called when both source file and cache file are "the same"
182+
- `options.hooks.notFound` **{Function}** - called when file is not found in
183+
cache (usually the first hit)
184+
- `options.hooks.changed` **{Function}** - called always when source file
185+
differs the cache file
186+
- `options.hooks.notChanged` **{Function}** - called when both source file and
187+
cache file are "the same"
180188
- `options.hooks.always` **{Function}** - called always, no matter of the state
181-
- `options.glob` **{Function}** - a function `(patterns, options) => {}` or globbing library like [glob][], [globby][], [fast-glob][]
182-
- `options.globOptions` **{object}** - options passed to the `options.glob` library
183-
- `options.cacheLocation` **{string}** - a filepath location of the cache, defaults to `.cache/glob-cache` in `options.cwd`
189+
- `options.glob` **{Function}** - a function `(patterns, options) => {}` or
190+
globbing library like [glob][], [globby][], [fast-glob][]
191+
- `options.globOptions` **{object}** - options passed to the `options.glob`
192+
library
193+
- `options.cacheLocation` **{string}** - a filepath location of the cache,
194+
defaults to `.cache/glob-cache` in `options.cwd`
184195
- `returns` **{AsyncIterable}**
185196
186197
<span id="globcache.stream-examples"></span>
@@ -194,7 +205,7 @@ const globCache = require('glob-cache');
194205
// Using the Stream API
195206
const iterable = globCache.stream({
196207
include: 'src/*.js',
197-
cacheLocation: './foo-cache'
208+
cacheLocation: './foo-cache',
198209
});
199210

200211
for await (const ctx of iterable) {
@@ -205,8 +216,8 @@ const globCache = require('glob-cache');
205216
206217
### [globCache.promise](./src/index.js#L243)
207218
208-
Using the Promise API allows you to use the Hooks API, and it's actually
209-
the recommended way of using the hooks api. By default, if the returned promise
219+
Using the Promise API allows you to use the Hooks API, and it's actually the
220+
recommended way of using the hooks api. By default, if the returned promise
210221
resolves, it will be an empty array. That's intentional, because if you are
211222
using the hooks api it's unnecessary to pollute the memory putting huge objects
212223
to a "result array". So if you want results array to contain the Context objects
@@ -224,9 +235,12 @@ function(options)
224235

225236
#### Params
226237

227-
- `options` **{object}** - see `globCache.stream` options, in addition here we have `options.buffered` too
228-
- `options.buffered` **{boolean}** - if `true` returned array will contain [Context]((#context-and-how-it-works)) objects, default `false`
229-
- `returns` **{Promise}** - if `options.buffered: true` resolves to `Array<Context>`, otherwise empty array
238+
- `options` **{object}** - see `globCache.stream` options, in addition here we
239+
have `options.buffered` too
240+
- `options.buffered` **{boolean}** - if `true` returned array will contain
241+
[Context](<(#context-and-how-it-works)>) objects, default `false`
242+
- `returns` **{Promise}** - if `options.buffered: true` resolves to
243+
`Array<Context>`, otherwise empty array
230244

231245
<span id="globcache.promise-examples"></span>
232246

@@ -245,7 +259,7 @@ const globby = require('globby');
245259
hooks: {
246260
changed(ctx) {},
247261
always(ctx) {},
248-
}
262+
},
249263
});
250264
console.log(res); // => []
251265
@@ -465,10 +479,9 @@ your [support](#support-the-project) to them:
465479
466480
## License
467481
468-
Copyright (c) 2020-present,
469-
[Charlike Mike Reagent](https://tunnckocore.com) `<opensource@tunnckocore.com>`
470-
& [contributors](#wonderful-contributors).<br> Released under the
471-
[MPL-2.0 License][license-url].
482+
Copyright (c) 2020-present, [Charlike Mike Reagent](https://tunnckocore.com)
483+
`<opensource@tunnckocore.com>` & [contributors](#wonderful-contributors).<br>
484+
Released under the [MPL-2.0 License][license-url].
472485
473486
<!-- badges -->
474487
@@ -498,7 +511,7 @@ Copyright (c) 2020-present,
498511
[codestyle-img]: https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb&cache=300
499512
500513
[linuxbuild-url]: https://github.com/tunnckocore/opensource/actions
501-
[linuxbuild-img]: https://badgen.net/github/checks/tunnckoCore/opensource/master?cache=300&label=build&icon=github
514+
[linuxbuild-img]: https://badgen-net.charlike.now.sh/github/checks/tunnckoCore/opensource/master/test?cache=300&label=build&icon=github
502515
503516
[ccommits-url]: https://conventionalcommits.org/
504517
[ccommits-img]: https://badgen.net/badge/conventional%20commits/v1.0.0/green?cache=300
@@ -563,4 +576,4 @@ Copyright (c) 2020-present,
563576
[fast-glob]: https://github.com/mrmlnc/fast-glob
564577
[glob]: https://github.com/isaacs/node-glob
565578
[globby]: https://github.com/sindresorhus/globby
566-
[tiny-glob]: https://github.com/terkelg/tiny-glob
579+
[tiny-glob]: https://github.com/terkelg/tiny-glob

@packages/glob-cache/docs/src/index.md

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
2-
31
_Generated using [jest-runner-docs](https://ghub.now.sh/jest-runner-docs)._
42

53
### [globCache](./src/index.js#L40)
64

7-
A mirror of `globCache.stream` and so an "async generator" function,
8-
returning an AsyncIterable. This mirror exists because it's
9-
a common practice to have a `(globPatterns, options)` signature.
5+
A mirror of `globCache.stream` and so an "async generator" function, returning
6+
an AsyncIterable. This mirror exists because it's a common practice to have a
7+
`(globPatterns, options)` signature.
108

119
<span id="globcache-signature"></span>
1210

@@ -23,8 +21,6 @@ function(patterns, options)
2321
- `patterns` **{string|Array}** - string or array of glob patterns
2422
- `options` **{object}** - see `globCache.stream` options
2523

26-
27-
2824
<span id="globcache-examples"></span>
2925

3026
#### Examples
@@ -33,24 +29,25 @@ function(patterns, options)
3329
const globCache = require('glob-cache');
3430
3531
const iterable = globCache(['src/*.js', 'test/*.{js,ts}'], {
36-
cwd: './foo/bar'
32+
cwd: './foo/bar',
3733
});
3834
3935
// equivalent to
4036
4137
const iter = globCache.stream({
4238
include: ['src/*.js', 'test/*.{js,ts}'],
43-
cwd: './foo/bar'
39+
cwd: './foo/bar',
4440
});
4541
```
4642

4743
### [globCache.stream](./src/index.js#L84)
4844

49-
Match files and folders with glob patterns, by default using [fast-glob's `.stream()`](https://ghub.now.sh/fast-glob).
50-
This function is [async generator](https://javascript.info/async-iterators-generators)
51-
and returns "async iterable", so you can use the `for await ... of` loop. Note that this loop
52-
should be used inside an `async function`.
53-
Each item is a [Context](#context-and-how-it-works) object, which is also passed to each hook.
45+
Match files and folders with glob patterns, by default using
46+
[fast-glob's `.stream()`](https://ghub.now.sh/fast-glob). This function is
47+
[async generator](https://javascript.info/async-iterators-generators) and
48+
returns "async iterable", so you can use the `for await ... of` loop. Note that
49+
this loop should be used inside an `async function`. Each item is a
50+
[Context](#context-and-how-it-works) object, which is also passed to each hook.
5451

5552
<span id="globcache.stream-signature"></span>
5653

@@ -67,21 +64,27 @@ function(options)
6764
- `options.cwd` **{string}** - working directory, defaults to `process.cwd()`
6865
- `options.include` **{string|Array}** - string or array of string glob patterns
6966
- `options.patterns` **{string|Array}** - alias of `options.include`
70-
- `options.exclude` **{string|Array}** - ignore glob patterns, passed to `options.globOptions.ignore`
67+
- `options.exclude` **{string|Array}** - ignore glob patterns, passed to
68+
`options.globOptions.ignore`
7169
- `options.ignore` **{string|Array}** - alias of `options.exclude`
72-
- `options.hooks` **{object}** - an object with hooks functions, each hook passed with [Context](#context-and-how-it-works)
70+
- `options.hooks` **{object}** - an object with hooks functions, each hook
71+
passed with [Context](#context-and-how-it-works)
7372
- `options.hooks.found` **{Function}** - called when a cache for a file is found
74-
- `options.hooks.notFound` **{Function}** - called when file is not found in cache (usually the first hit)
75-
- `options.hooks.changed` **{Function}** - called always when source file differs the cache file
76-
- `options.hooks.notChanged` **{Function}** - called when both source file and cache file are "the same"
73+
- `options.hooks.notFound` **{Function}** - called when file is not found in
74+
cache (usually the first hit)
75+
- `options.hooks.changed` **{Function}** - called always when source file
76+
differs the cache file
77+
- `options.hooks.notChanged` **{Function}** - called when both source file and
78+
cache file are "the same"
7779
- `options.hooks.always` **{Function}** - called always, no matter of the state
78-
- `options.glob` **{Function}** - a function `(patterns, options) => {}` or globbing library like [glob][], [globby][], [fast-glob][]
79-
- `options.globOptions` **{object}** - options passed to the `options.glob` library
80-
- `options.cacheLocation` **{string}** - a filepath location of the cache, defaults to `.cache/glob-cache` in `options.cwd`
80+
- `options.glob` **{Function}** - a function `(patterns, options) => {}` or
81+
globbing library like [glob][], [globby][], [fast-glob][]
82+
- `options.globOptions` **{object}** - options passed to the `options.glob`
83+
library
84+
- `options.cacheLocation` **{string}** - a filepath location of the cache,
85+
defaults to `.cache/glob-cache` in `options.cwd`
8186
- `returns` **{AsyncIterable}**
8287
83-
84-
8588
<span id="globcache.stream-examples"></span>
8689
8790
#### Examples
@@ -93,7 +96,7 @@ const globCache = require('glob-cache');
9396
// Using the Stream API
9497
const iterable = globCache.stream({
9598
include: 'src/*.js',
96-
cacheLocation: './foo-cache'
99+
cacheLocation: './foo-cache',
97100
});
98101

99102
for await (const ctx of iterable) {
@@ -104,8 +107,8 @@ const globCache = require('glob-cache');
104107
105108
### [globCache.promise](./src/index.js#L243)
106109
107-
Using the Promise API allows you to use the Hooks API, and it's actually
108-
the recommended way of using the hooks api. By default, if the returned promise
110+
Using the Promise API allows you to use the Hooks API, and it's actually the
111+
recommended way of using the hooks api. By default, if the returned promise
109112
resolves, it will be an empty array. That's intentional, because if you are
110113
using the hooks api it's unnecessary to pollute the memory putting huge objects
111114
to a "result array". So if you want results array to contain the Context objects
@@ -123,11 +126,12 @@ function(options)
123126

124127
#### Params
125128

126-
- `options` **{object}** - see `globCache.stream` options, in addition here we have `options.buffered` too
127-
- `options.buffered` **{boolean}** - if `true` returned array will contain [Context]((#context-and-how-it-works)) objects, default `false`
128-
- `returns` **{Promise}** - if `options.buffered: true` resolves to `Array<Context>`, otherwise empty array
129-
130-
129+
- `options` **{object}** - see `globCache.stream` options, in addition here we
130+
have `options.buffered` too
131+
- `options.buffered` **{boolean}** - if `true` returned array will contain
132+
[Context](<(#context-and-how-it-works)>) objects, default `false`
133+
- `returns` **{Promise}** - if `options.buffered: true` resolves to
134+
`Array<Context>`, otherwise empty array
131135

132136
<span id="globcache.promise-examples"></span>
133137

@@ -146,7 +150,7 @@ const globby = require('globby');
146150
hooks: {
147151
changed(ctx) {},
148152
always(ctx) {},
149-
}
153+
},
150154
});
151155
console.log(res); // => []
152156
@@ -160,4 +164,3 @@ const globby = require('globby');
160164
console.log(results); // => [Context, Context, ...]
161165
})();
162166
```
163-

0 commit comments

Comments
 (0)