Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : async.ts
import AsyncReader from '../readers/async';
import Settings from '../settings';
import { Entry, Errno } from '../types';

type FailureCallback = (err: Errno) => void;
type SuccessCallback = (err: null, entries: Entry[]) => void;

export type AsyncCallback = (err: Errno, entries: Entry[]) => void;

export default class AsyncProvider {
	protected readonly _reader: AsyncReader = new AsyncReader(this._root, this._settings);

	private readonly _storage: Set<Entry> = new Set();

	constructor(private readonly _root: string, private readonly _settings: Settings) { }

	public read(callback: AsyncCallback): void {
		this._reader.onError((error) => {
			callFailureCallback(callback, error);
		});

		this._reader.onEntry((entry: Entry) => {
			this._storage.add(entry);
		});

		this._reader.onEnd(() => {
			callSuccessCallback(callback, [...this._storage]);
		});

		this._reader.read();
	}
}

function callFailureCallback(callback: AsyncCallback, error: Errno): void {
	(callback as FailureCallback)(error);
}

function callSuccessCallback(callback: AsyncCallback, entries: Entry[]): void {
	(callback as unknown as SuccessCallback)(null, entries);
}
© 2026 GrazzMean