aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@nodelib/fs.walk/out/readers
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
commitd25e11bee6ca5ca523884da132d18e1400e077b9 (patch)
tree8af39fde19f7ed640a60fb397c7edd647dff1c4c /node_modules/@nodelib/fs.walk/out/readers
downloadkartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip
Initial commit
Diffstat (limited to 'node_modules/@nodelib/fs.walk/out/readers')
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/async.d.ts30
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/async.js97
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/common.d.ts7
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/common.js31
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/reader.d.ts6
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/reader.js11
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/sync.d.ts15
-rw-r--r--node_modules/@nodelib/fs.walk/out/readers/sync.js59
8 files changed, 256 insertions, 0 deletions
diff --git a/node_modules/@nodelib/fs.walk/out/readers/async.d.ts b/node_modules/@nodelib/fs.walk/out/readers/async.d.ts
new file mode 100644
index 0000000..9acf4e6
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/async.d.ts
@@ -0,0 +1,30 @@
+/// <reference types="node" />
+import { EventEmitter } from 'events';
+import * as fsScandir from '@nodelib/fs.scandir';
+import type Settings from '../settings';
+import type { Entry, Errno } from '../types';
+import Reader from './reader';
+declare type EntryEventCallback = (entry: Entry) => void;
+declare type ErrorEventCallback = (error: Errno) => void;
+declare type EndEventCallback = () => void;
+export default class AsyncReader extends Reader {
+ protected readonly _settings: Settings;
+ protected readonly _scandir: typeof fsScandir.scandir;
+ protected readonly _emitter: EventEmitter;
+ private readonly _queue;
+ private _isFatalError;
+ private _isDestroyed;
+ constructor(_root: string, _settings: Settings);
+ read(): EventEmitter;
+ get isDestroyed(): boolean;
+ destroy(): void;
+ onEntry(callback: EntryEventCallback): void;
+ onError(callback: ErrorEventCallback): void;
+ onEnd(callback: EndEventCallback): void;
+ private _pushToQueue;
+ private _worker;
+ private _handleError;
+ private _handleEntry;
+ private _emitEntry;
+}
+export {};
diff --git a/node_modules/@nodelib/fs.walk/out/readers/async.js b/node_modules/@nodelib/fs.walk/out/readers/async.js
new file mode 100644
index 0000000..ebe8dd5
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/async.js
@@ -0,0 +1,97 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const events_1 = require("events");
+const fsScandir = require("@nodelib/fs.scandir");
+const fastq = require("fastq");
+const common = require("./common");
+const reader_1 = require("./reader");
+class AsyncReader extends reader_1.default {
+ constructor(_root, _settings) {
+ super(_root, _settings);
+ this._settings = _settings;
+ this._scandir = fsScandir.scandir;
+ this._emitter = new events_1.EventEmitter();
+ this._queue = fastq(this._worker.bind(this), this._settings.concurrency);
+ this._isFatalError = false;
+ this._isDestroyed = false;
+ this._queue.drain = () => {
+ if (!this._isFatalError) {
+ this._emitter.emit('end');
+ }
+ };
+ }
+ read() {
+ this._isFatalError = false;
+ this._isDestroyed = false;
+ setImmediate(() => {
+ this._pushToQueue(this._root, this._settings.basePath);
+ });
+ return this._emitter;
+ }
+ get isDestroyed() {
+ return this._isDestroyed;
+ }
+ destroy() {
+ if (this._isDestroyed) {
+ throw new Error('The reader is already destroyed');
+ }
+ this._isDestroyed = true;
+ this._queue.killAndDrain();
+ }
+ onEntry(callback) {
+ this._emitter.on('entry', callback);
+ }
+ onError(callback) {
+ this._emitter.once('error', callback);
+ }
+ onEnd(callback) {
+ this._emitter.once('end', callback);
+ }
+ _pushToQueue(directory, base) {
+ const queueItem = { directory, base };
+ this._queue.push(queueItem, (error) => {
+ if (error !== null) {
+ this._handleError(error);
+ }
+ });
+ }
+ _worker(item, done) {
+ this._scandir(item.directory, this._settings.fsScandirSettings, (error, entries) => {
+ if (error !== null) {
+ done(error, undefined);
+ return;
+ }
+ for (const entry of entries) {
+ this._handleEntry(entry, item.base);
+ }
+ done(null, undefined);
+ });
+ }
+ _handleError(error) {
+ if (this._isDestroyed || !common.isFatalError(this._settings, error)) {
+ return;
+ }
+ this._isFatalError = true;
+ this._isDestroyed = true;
+ this._emitter.emit('error', error);
+ }
+ _handleEntry(entry, base) {
+ if (this._isDestroyed || this._isFatalError) {
+ return;
+ }
+ const fullpath = entry.path;
+ if (base !== undefined) {
+ entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
+ }
+ if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
+ this._emitEntry(entry);
+ }
+ if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
+ this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
+ }
+ }
+ _emitEntry(entry) {
+ this._emitter.emit('entry', entry);
+ }
+}
+exports.default = AsyncReader;
diff --git a/node_modules/@nodelib/fs.walk/out/readers/common.d.ts b/node_modules/@nodelib/fs.walk/out/readers/common.d.ts
new file mode 100644
index 0000000..5985f97
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/common.d.ts
@@ -0,0 +1,7 @@
+import type { FilterFunction } from '../settings';
+import type Settings from '../settings';
+import type { Errno } from '../types';
+export declare function isFatalError(settings: Settings, error: Errno): boolean;
+export declare function isAppliedFilter<T>(filter: FilterFunction<T> | null, value: T): boolean;
+export declare function replacePathSegmentSeparator(filepath: string, separator: string): string;
+export declare function joinPathSegments(a: string, b: string, separator: string): string;
diff --git a/node_modules/@nodelib/fs.walk/out/readers/common.js b/node_modules/@nodelib/fs.walk/out/readers/common.js
new file mode 100644
index 0000000..a93572f
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/common.js
@@ -0,0 +1,31 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.joinPathSegments = exports.replacePathSegmentSeparator = exports.isAppliedFilter = exports.isFatalError = void 0;
+function isFatalError(settings, error) {
+ if (settings.errorFilter === null) {
+ return true;
+ }
+ return !settings.errorFilter(error);
+}
+exports.isFatalError = isFatalError;
+function isAppliedFilter(filter, value) {
+ return filter === null || filter(value);
+}
+exports.isAppliedFilter = isAppliedFilter;
+function replacePathSegmentSeparator(filepath, separator) {
+ return filepath.split(/[/\\]/).join(separator);
+}
+exports.replacePathSegmentSeparator = replacePathSegmentSeparator;
+function joinPathSegments(a, b, separator) {
+ if (a === '') {
+ return b;
+ }
+ /**
+ * The correct handling of cases when the first segment is a root (`/`, `C:/`) or UNC path (`//?/C:/`).
+ */
+ if (a.endsWith(separator)) {
+ return a + b;
+ }
+ return a + separator + b;
+}
+exports.joinPathSegments = joinPathSegments;
diff --git a/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts b/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts
new file mode 100644
index 0000000..e1f383b
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/reader.d.ts
@@ -0,0 +1,6 @@
+import type Settings from '../settings';
+export default class Reader {
+ protected readonly _root: string;
+ protected readonly _settings: Settings;
+ constructor(_root: string, _settings: Settings);
+}
diff --git a/node_modules/@nodelib/fs.walk/out/readers/reader.js b/node_modules/@nodelib/fs.walk/out/readers/reader.js
new file mode 100644
index 0000000..782f07c
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/reader.js
@@ -0,0 +1,11 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const common = require("./common");
+class Reader {
+ constructor(_root, _settings) {
+ this._root = _root;
+ this._settings = _settings;
+ this._root = common.replacePathSegmentSeparator(_root, _settings.pathSegmentSeparator);
+ }
+}
+exports.default = Reader;
diff --git a/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts b/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts
new file mode 100644
index 0000000..af41033
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/sync.d.ts
@@ -0,0 +1,15 @@
+import * as fsScandir from '@nodelib/fs.scandir';
+import type { Entry } from '../types';
+import Reader from './reader';
+export default class SyncReader extends Reader {
+ protected readonly _scandir: typeof fsScandir.scandirSync;
+ private readonly _storage;
+ private readonly _queue;
+ read(): Entry[];
+ private _pushToQueue;
+ private _handleQueue;
+ private _handleDirectory;
+ private _handleError;
+ private _handleEntry;
+ private _pushToStorage;
+}
diff --git a/node_modules/@nodelib/fs.walk/out/readers/sync.js b/node_modules/@nodelib/fs.walk/out/readers/sync.js
new file mode 100644
index 0000000..9a8d5a6
--- /dev/null
+++ b/node_modules/@nodelib/fs.walk/out/readers/sync.js
@@ -0,0 +1,59 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const fsScandir = require("@nodelib/fs.scandir");
+const common = require("./common");
+const reader_1 = require("./reader");
+class SyncReader extends reader_1.default {
+ constructor() {
+ super(...arguments);
+ this._scandir = fsScandir.scandirSync;
+ this._storage = [];
+ this._queue = new Set();
+ }
+ read() {
+ this._pushToQueue(this._root, this._settings.basePath);
+ this._handleQueue();
+ return this._storage;
+ }
+ _pushToQueue(directory, base) {
+ this._queue.add({ directory, base });
+ }
+ _handleQueue() {
+ for (const item of this._queue.values()) {
+ this._handleDirectory(item.directory, item.base);
+ }
+ }
+ _handleDirectory(directory, base) {
+ try {
+ const entries = this._scandir(directory, this._settings.fsScandirSettings);
+ for (const entry of entries) {
+ this._handleEntry(entry, base);
+ }
+ }
+ catch (error) {
+ this._handleError(error);
+ }
+ }
+ _handleError(error) {
+ if (!common.isFatalError(this._settings, error)) {
+ return;
+ }
+ throw error;
+ }
+ _handleEntry(entry, base) {
+ const fullpath = entry.path;
+ if (base !== undefined) {
+ entry.path = common.joinPathSegments(base, entry.name, this._settings.pathSegmentSeparator);
+ }
+ if (common.isAppliedFilter(this._settings.entryFilter, entry)) {
+ this._pushToStorage(entry);
+ }
+ if (entry.dirent.isDirectory() && common.isAppliedFilter(this._settings.deepFilter, entry)) {
+ this._pushToQueue(fullpath, base === undefined ? undefined : entry.path);
+ }
+ }
+ _pushToStorage(entry) {
+ this._storage.push(entry);
+ }
+}
+exports.default = SyncReader;