Home Reference Source

Function

Static Public Summary
public

byDirname(paths: string[]): Object

Group paths by their parent path.

public

isAscendant(subject: string, descendant: string): boolean

Whether a path is an ascendant of another one.

public

isDescendant(subject: string, ascendant: string): boolean

Whether a path is an descendant of another one.

public

isDir(path: string | Buffer | URL): Promise<boolean>

Whether a file is a directory or not.

public

Whether a path is unique and does not have any ascendant within an array of paths.

Static Public

public byDirname(paths: string[]): Object source

import {byDirname} from 'files-by-directory/src/path.js'

Group paths by their parent path.

Params:

NameTypeAttributeDescription
paths string[]

Paths.

Return:

Object

Plain object indexed by parent paths containing paths arrays.

public isAscendant(subject: string, descendant: string): boolean source

import {isAscendant} from 'files-by-directory/src/path.js'

Whether a path is an ascendant of another one.

Params:

NameTypeAttributeDescription
subject string

ascendant path.

descendant string

descendant path.

Return:

boolean

true if subject is an ascendant of descendant, false otherwise.

public isDescendant(subject: string, ascendant: string): boolean source

import {isDescendant} from 'files-by-directory/src/path.js'

Whether a path is an descendant of another one.

Params:

NameTypeAttributeDescription
subject string

descendant path.

ascendant string

ascendant path.

Return:

boolean

true if subject is an ascendant of ascendant, false otherwise.

public isDir(path: string | Buffer | URL): Promise<boolean> source

import {isDir} from 'files-by-directory/src/fs.js'

Whether a file is a directory or not.

Params:

NameTypeAttributeDescription
path string | Buffer | URL

Return:

Promise<boolean>

true if the file is a directory, false otherwise.

public isUniqueAndNotDescendant(path: string, index: number, paths: string[]): boolean source

import {isUniqueAndNotDescendant} from 'files-by-directory/src/path.js'

Whether a path is unique and does not have any ascendant within an array of paths.

Params:

NameTypeAttributeDescription
path string

A path.

index number

Index of path with

paths string[]

Array of paths.

Return:

boolean

true if path is both unique and do not have any ascendant within paths, false otherwise.