Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UniversalPath

Class representing some kind of filesystem resource.

Hierarchy

  • UniversalPath

Index

Constructors

constructor

Properties

Protected Optional Readonly filesystem

filesystem: Filesystem

Protected Readonly initial

initial: string

Protected resourceLocalPath

resourceLocalPath: string

Protected resourcePrefix

resourcePrefix: string

Accessors

charset

  • get charset(): string | false

contentType

  • get contentType(): string | false

ext

  • get ext(): string
  • Get the extension of the resource referred to by this instance.

    example
    const myFile = universalPath('home', 'user', 'file.txt')
    
    myFile.ext  // => 'txt'
    

    Returns string

isLocal

  • get isLocal(): boolean

isRemote

  • get isRemote(): boolean

mimeType

  • get mimeType(): string | false

prefix

  • get prefix(): string

toBase

  • get toBase(): string

toLocal

  • get toLocal(): string

toRemote

  • get toRemote(): string

unqualified

  • get unqualified(): string

Methods

append

clone

concat

  • Append and resolve the given paths to this resource and return a new UniversalPath.

    example
    const homeDir = universalPath('home', 'user')
    
    homeDir.concat('file.txt').toLocal  // => /home/user/file.txt
    
    homeDir.concat('..', 'other_user').toLocal  // => /home/other_user
    

    Parameters

    Returns UniversalPath

exists

  • exists(): Promise<boolean>

is

isChildOf

isDirectory

  • isDirectory(): Promise<boolean>

isFile

  • isFile(): Promise<boolean>

isParentOf

list

mkdir

  • mkdir(): Promise<void>
  • Recursively create this path as a directory. Equivalent to mkdir -p on Linux.

    Returns Promise<void>

read

  • read(): Promise<string>

readStream

  • readStream(): Promise<Readable>

Protected setLocal

  • setLocal(): void
  • Determine the "localized" string of this path.

    This is the normalized path WITHOUT the prefix.

    example

    The normalized path of "file:///home/user/file.txt" is "/home/user/file.txt".

    Returns void

Protected setPrefix

  • setPrefix(): void

sizeForHumans

  • sizeForHumans(): Promise<string>

sizeInBytes

  • sizeInBytes(): Promise<number>

toString

  • toString(): string

walk

  • walk(): any
  • Recursively walk all files in this directory. Must be a local resource.

    This returns an async generator function.

    example
    const configFiles = universalPath('home', 'user', '.config')
    
    for await (const configFile of configFiles.walk()) {
        // configFile is a string
        // ... do something ...
    }
    

    Returns any

write

  • write(data: string | Buffer): Promise<void>
  • Write the given data to this resource as a file.

    Parameters

    • data: string | Buffer

    Returns Promise<void>

writeStream

  • writeStream(): Promise<Writable>
Extollo Logo

extollo (v. latin) - to lift up, to elevate

Extollo is a free & libre application framework in TypeScript.