PackwizJS/docs/resource/classes/Resource.md

188 lines
2.3 KiB
Markdown
Raw Normal View History

2025-02-09 10:00:02 -06:00
[**packwizjs**](../../README.md)
***
[packwizjs](../../modules.md) / [resource](../README.md) / Resource
# Class: Resource
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:8
Resource class for handling file and URL paths.
2025-02-09 10:00:02 -06:00
## Constructors
### new Resource()
> **new Resource**(`path`): [`Resource`](Resource.md)
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:13
Creates a new Resource instance.
2025-02-09 10:00:02 -06:00
#### Parameters
##### path
`string`
2025-02-09 10:10:56 -06:00
The file or URL path.
2025-02-09 10:00:02 -06:00
#### Returns
[`Resource`](Resource.md)
## Properties
### path
> `readonly` **path**: `string`
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:13
The file or URL path.
2025-02-09 10:00:02 -06:00
## Accessors
### ext
#### Get Signature
> **get** **ext**(): `string`
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:63
Gets the file extension of the file or URL.
2025-02-09 10:00:02 -06:00
##### Returns
`string`
2025-02-09 10:10:56 -06:00
The file extension of the file or URL.
2025-02-09 10:00:02 -06:00
***
### isUrl
#### Get Signature
> **get** **isUrl**(): `boolean`
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:27
Checks if the path is a valid URL.
2025-02-09 10:00:02 -06:00
##### Returns
`boolean`
2025-02-09 10:10:56 -06:00
True if the path is a valid URL, false otherwise.
2025-02-09 10:00:02 -06:00
***
### name
#### Get Signature
> **get** **name**(): `string`
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:40
Gets the name of the file or URL.
2025-02-09 10:00:02 -06:00
##### Returns
`string`
2025-02-09 10:10:56 -06:00
The name of the file or URL.
2025-02-09 10:00:02 -06:00
***
### parent
#### Get Signature
> **get** **parent**(): [`Resource`](Resource.md)
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:50
Gets the parent directory of the file or URL.
2025-02-09 10:00:02 -06:00
##### Returns
[`Resource`](Resource.md)
2025-02-09 10:10:56 -06:00
The parent directory of the file or URL.
2025-02-09 10:00:02 -06:00
## Methods
### exists()
> **exists**(): `Promise`\<`boolean`\>
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:73
Checks if the file or URL exists.
2025-02-09 10:00:02 -06:00
#### Returns
`Promise`\<`boolean`\>
2025-02-09 10:10:56 -06:00
True if the file or URL exists, false otherwise.
2025-02-09 10:00:02 -06:00
***
### fetchContents()
> **fetchContents**(): `Promise`\<`string`\>
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:87
Fetches the contents of the file or URL.
2025-02-09 10:00:02 -06:00
#### Returns
`Promise`\<`string`\>
2025-02-09 10:10:56 -06:00
The contents of file the Resource points to.
2025-02-09 10:00:02 -06:00
***
### join()
> **join**(...`segments`): [`Resource`](Resource.md)
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:102
Joins the Resource with other segments to create a new Resource.
2025-02-09 10:00:02 -06:00
#### Parameters
##### segments
...`string`[]
2025-02-09 10:10:56 -06:00
The segments to join with the Resource.
2025-02-09 10:00:02 -06:00
#### Returns
[`Resource`](Resource.md)
2025-02-09 10:10:56 -06:00
A new Resource instance with the joined path.
2025-02-09 10:00:02 -06:00
***
### toString()
> **toString**(): `string`
2025-02-09 10:10:56 -06:00
Defined in: resource.ts:19
Returns the string representation of the Resource instance.
2025-02-09 10:00:02 -06:00
#### Returns
`string`
2025-02-09 10:10:56 -06:00
The path of the Resource.