Skip to content

List

ts
import { Directory } from './dir.js';
import { DirentWrapper } from '../wrapper/dirent.js';
import type { LoomFile } from './file.js';
import { ObjectDirentInterface } from '../definitions.js';
export type ListTypes = LoomFile | Directory;
type PickMatching<T, V> = {
    [K in keyof T as T[K] extends V ? K : never]: T[K];
};
type DirentMethodsName = keyof PickMatching<DirentWrapper, () => unknown>;
export declare class List<T extends ListTypes = ListTypes> {
    protected _dirent: DirentWrapper[];
    static from<T extends ListTypes>(list: List<T>): List<T>;
    static from<T extends ListTypes>(direntWraps: DirentWrapper[]): List<T>;
    constructor();
    constructor(dir: Directory, paths: ObjectDirentInterface[]);
    protected add(paths: DirentWrapper[]): void;
    protected add(list: List<T>): void;
    protected add(listOrWrap: List<T> | DirentWrapper[]): void;
    concat<U extends ListTypes>(...lists: Array<List<U>>): List<T | U>;
    get length(): number;
    protected convert(wrap: DirentWrapper): LoomFile<import("../definitions.js").SourceAdapter<import("../definitions.js").FileStat>> | Directory;
    at(index: number): LoomFile<import("../definitions.js").SourceAdapter<import("../definitions.js").FileStat>> | Directory;
    first<T = Directory | LoomFile>(): T;
    last<T = Directory | LoomFile>(): T;
    asArray(): Array<T>;
    filter<T extends ListTypes>(fn: (wrap: DirentWrapper) => boolean): List<T>;
    only(type: 'directories' | 'dirs'): List<Directory>;
    only(type: 'files'): List<LoomFile>;
    /**
       * @deprecated Deprecated use only instead
       */
    filterByType(direntMethod: DirentMethodsName): List<ListTypes>;
    [Symbol.iterator](): IterableIterator<T>;
    get [Symbol.toStringTag](): string;
}
export {};