1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | exports.Settings = exports.walkStream = exports.walkSync = exports.walk = void 0;
|
---|
4 | const async_1 = require("./providers/async");
|
---|
5 | const stream_1 = require("./providers/stream");
|
---|
6 | const sync_1 = require("./providers/sync");
|
---|
7 | const settings_1 = require("./settings");
|
---|
8 | exports.Settings = settings_1.default;
|
---|
9 | function walk(directory, optionsOrSettingsOrCallback, callback) {
|
---|
10 | if (typeof optionsOrSettingsOrCallback === 'function') {
|
---|
11 | new async_1.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
|
---|
12 | return;
|
---|
13 | }
|
---|
14 | new async_1.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
|
---|
15 | }
|
---|
16 | exports.walk = walk;
|
---|
17 | function walkSync(directory, optionsOrSettings) {
|
---|
18 | const settings = getSettings(optionsOrSettings);
|
---|
19 | const provider = new sync_1.default(directory, settings);
|
---|
20 | return provider.read();
|
---|
21 | }
|
---|
22 | exports.walkSync = walkSync;
|
---|
23 | function walkStream(directory, optionsOrSettings) {
|
---|
24 | const settings = getSettings(optionsOrSettings);
|
---|
25 | const provider = new stream_1.default(directory, settings);
|
---|
26 | return provider.read();
|
---|
27 | }
|
---|
28 | exports.walkStream = walkStream;
|
---|
29 | function getSettings(settingsOrOptions = {}) {
|
---|
30 | if (settingsOrOptions instanceof settings_1.default) {
|
---|
31 | return settingsOrOptions;
|
---|
32 | }
|
---|
33 | return new settings_1.default(settingsOrOptions);
|
---|
34 | }
|
---|