Skip to content

Commit fc3b6b9

Browse files
committed
docs: fix makeRe example
1 parent bf6a33b commit fc3b6b9

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,17 @@ Compile a regular expression from the `state` object returned by the
265265
* `returnState` **{Boolean}**: Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
266266
* `returns` **{RegExp}**
267267
268+
**Example**
269+
270+
```js
271+
const picomatch = require('picomatch');
272+
const state = picomatch.parse('*.js');
273+
// picomatch.compileRe(state[, options]);
274+
275+
console.log(picomatch.compileRe(state));
276+
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
277+
```
278+
268279
### [.makeRe](lib/picomatch.js#L285)
269280
270281
Create a regular expression from a parsed glob pattern.
@@ -281,10 +292,10 @@ Create a regular expression from a parsed glob pattern.
281292
282293
```js
283294
const picomatch = require('picomatch');
284-
const state = picomatch.parse('*.js');
285-
// picomatch.compileRe(state[, options]);
295+
// picomatch.makeRe(state[, options]);
286296

287-
console.log(picomatch.compileRe(state));
297+
const result = picomatch.makeRe('*.js');
298+
console.log(result);
288299
//=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
289300
```
290301

lib/picomatch.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ picomatch.scan = (input, options) => scan(input, options);
233233
* Compile a regular expression from the `state` object returned by the
234234
* [parse()](#parse) method.
235235
*
236+
* ```js
237+
* const picomatch = require('picomatch');
238+
* const state = picomatch.parse('*.js');
239+
* // picomatch.compileRe(state[, options]);
240+
*
241+
* console.log(picomatch.compileRe(state));
242+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
243+
* ```
236244
* @param {Object} `state`
237245
* @param {Object} `options`
238246
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
@@ -268,10 +276,10 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false
268276
*
269277
* ```js
270278
* const picomatch = require('picomatch');
271-
* const state = picomatch.parse('*.js');
272-
* // picomatch.compileRe(state[, options]);
279+
* // picomatch.makeRe(state[, options]);
273280
*
274-
* console.log(picomatch.compileRe(state));
281+
* const result = picomatch.makeRe('*.js');
282+
* console.log(result);
275283
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
276284
* ```
277285
* @param {String} `state` The object returned from the `.parse` method.

0 commit comments

Comments
 (0)