187 lines
2.3 KiB
Markdown
187 lines
2.3 KiB
Markdown
[**packwizjs**](../../README.md)
|
|
|
|
***
|
|
|
|
[packwizjs](../../modules.md) / [resource](../README.md) / Resource
|
|
|
|
# Class: Resource
|
|
|
|
Defined in: resource.ts:8
|
|
|
|
Resource class for handling file and URL paths.
|
|
|
|
## Constructors
|
|
|
|
### new Resource()
|
|
|
|
> **new Resource**(`path`): [`Resource`](Resource.md)
|
|
|
|
Defined in: resource.ts:13
|
|
|
|
Creates a new Resource instance.
|
|
|
|
#### Parameters
|
|
|
|
##### path
|
|
|
|
`string`
|
|
|
|
The file or URL path.
|
|
|
|
#### Returns
|
|
|
|
[`Resource`](Resource.md)
|
|
|
|
## 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`](Resource.md)
|
|
|
|
Defined in: resource.ts:50
|
|
|
|
Gets the parent directory of the file or URL.
|
|
|
|
##### Returns
|
|
|
|
[`Resource`](Resource.md)
|
|
|
|
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`](Resource.md)
|
|
|
|
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`](Resource.md)
|
|
|
|
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.
|