Skip to content

Commit

Permalink
Merge pull request #398 from mrmlnc/ISSUE-397_glob_aliases
Browse files Browse the repository at this point in the history
ISSUE-397: Provide glob, globSync and globSteam aliases
  • Loading branch information
mrmlnc authored May 14, 2023
2 parents cc5e9cc + 40df921 commit ba7e86c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ npm install fast-glob

```js
fg(patterns, [options])
fg.async(patterns, [options])
fg.glob(patterns, [options])
```

Returns a `Promise` with an array of matching entries.
Expand All @@ -158,6 +160,7 @@ const entries = await fg(['.editorconfig', '**/index.js'], { dot: true });

```js
fg.sync(patterns, [options])
fg.globSync(patterns, [options])
```

Returns an array of matching entries.
Expand All @@ -174,6 +177,7 @@ const entries = fg.sync(['.editorconfig', '**/index.js'], { dot: true });

```js
fg.stream(patterns, [options])
fg.globStream(patterns, [options])
```

Returns a [`ReadableStream`][node_js_stream_readable_streams] when the `data` event will be emitted with matching entry.
Expand Down
18 changes: 18 additions & 0 deletions src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { EntryItem, ErrnoException } from './types';
import * as fg from '.';

describe('Package', () => {
describe('.globSync', () => {
it('must be an alias for the .sync method', () => {
assert.strictEqual(fg.globSync, fg.sync);
});
});

describe('.sync', () => {
it('should throw an error when input values can not pass validation', () => {
const message = 'Patterns must be a string (non empty) or an array of strings';
Expand Down Expand Up @@ -52,6 +58,12 @@ describe('Package', () => {
});
});

describe('.glob', () => {
it('must be an alias for the .sync method', () => {
assert.strictEqual(fg.glob, fg.async);
});
});

describe('.async', () => {
it('should throw an error when input values can not pass validation', async () => {
const message = 'Patterns must be a string (non empty) or an array of strings';
Expand Down Expand Up @@ -99,6 +111,12 @@ describe('Package', () => {
});
});

describe('.globStream', () => {
it('must be an alias for the .sync method', () => {
assert.strictEqual(fg.globStream, fg.stream);
});
});

describe('.stream', () => {
it('should throw an error when input values can not pass validation', () => {
const message = 'Patterns must be a string (non empty) or an array of strings';
Expand Down
4 changes: 4 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace FastGlob {
export type Pattern = PatternInternal;
export type FileSystemAdapter = FileSystemAdapterInternal;

export const glob = FastGlob;
export const globSync = sync;
export const globStream = stream;

export const async = FastGlob;

export function sync(source: PatternInternal | PatternInternal[], options: OptionsInternal & EntryObjectPredicate): EntryInternal[];
Expand Down

0 comments on commit ba7e86c

Please sign in to comment.