PackwizJS/docs/resource/classes/Resource.md
2025-02-09 10:10:56 -06:00

2.3 KiB

packwizjs


packwizjs / resource / Resource

Class: Resource

Defined in: resource.ts:8

Resource class for handling file and URL paths.

Constructors

new Resource()

new Resource(path): Resource

Defined in: resource.ts:13

Creates a new Resource instance.

Parameters

path

string

The file or URL path.

Returns

Resource

Properties

path

readonly path: string

Defined in: resource.ts:13

The file or URL path.

Accessors

ext

Get Signature

get ext(): string

Defined in: resource.ts:63

Gets the file extension of the file or URL.

Returns

string

The file extension of the file or URL.


isUrl

Get Signature

get isUrl(): boolean

Defined in: resource.ts:27

Checks if the path is a valid URL.

Returns

boolean

True if the path is a valid URL, false otherwise.


name

Get Signature

get name(): string

Defined in: resource.ts:40

Gets the name of the file or URL.

Returns

string

The name of the file or URL.


parent

Get Signature

get parent(): Resource

Defined in: resource.ts:50

Gets the parent directory of the file or URL.

Returns

Resource

The parent directory of the file or URL.

Methods

exists()

exists(): Promise<boolean>

Defined in: resource.ts:73

Checks if the file or URL exists.

Returns

Promise<boolean>

True if the file or URL exists, false otherwise.


fetchContents()

fetchContents(): Promise<string>

Defined in: resource.ts:87

Fetches the contents of the file or URL.

Returns

Promise<string>

The contents of file the Resource points to.


join()

join(...segments): Resource

Defined in: resource.ts:102

Joins the Resource with other segments to create a new Resource.

Parameters

segments

...string[]

The segments to join with the Resource.

Returns

Resource

A new Resource instance with the joined path.


toString()

toString(): string

Defined in: resource.ts:19

Returns the string representation of the Resource instance.

Returns

string

The path of the Resource.