Skip to content

Commit

Permalink
feat: add isDynamicPattern method
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmlnc committed Sep 29, 2019
1 parent 1ab666a commit 3d012db
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,27 @@ Any correct pattern(s).

See [Options](#options-1) section.

#### `isDynamicPattern(pattern, [options])`

```js
fg.isDynamicPattern('*'); // true
fg.isDynamicPattern('abc'); // false
```

#### pattern

* Required: `true`
* Type: `string`

Any correct pattern.

#### [options]

* Required: `false`
* Type: [`Options`](#options-1)

See [Options](#options-1) section.

## Options

### Common options
Expand Down
10 changes: 10 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,14 @@ describe('Package', () => {
assert.deepStrictEqual(actual, expected);
});
});

describe('.isDynamicPattern', () => {
it('should return true for dynamic pattern', () => {
assert.ok(pkg.isDynamicPattern('*'));
});

it('should return false for static pattern', () => {
assert.ok(!pkg.isDynamicPattern('abc'));
});
});
});
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ namespace FastGlob {

return taskManager.generate(patterns, settings);
}

export function isDynamicPattern(source: PatternInternal, options?: OptionsInternal): boolean {
assertPatternsInput(source);

const settings = new Settings(options);

return utils.pattern.isDynamicPattern(source, settings);
}
}

function getWorks<T>(source: PatternInternal | PatternInternal[], _Provider: new (settings: Settings) => Provider<T>, options?: OptionsInternal): T[] {
Expand Down

0 comments on commit 3d012db

Please sign in to comment.