Extends
Members
engine :file.services.FileEngine
The file engine.
Methods
load(file, asyncopt)
Load file data through the appropriate driver.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
file |
string | The file name. | ||
async |
boolean |
<optional> |
false
|
Indicates that the call should be made async. |
Returns:
The content of the file.
- Type
- * | Promise.<*>
loadAsync(file)
Asynchronously load file data.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | The file name. |
Returns:
The content of the file.
- Type
- Promise.<*>
exists(file)
Check if file exists.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | The file name. |
Returns:
Indicates that toe file or folder exists.
- Type
- boolean
findFirst(files)
Find first existing file.
Parameters:
Name | Type | Description |
---|---|---|
files |
Array.<string> | List of file names. |
Returns:
The first found file in the list, or null if none is found.
- Type
- string | null
loadFirst(files, asyncopt)
Load first existing file.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
files |
Array.<string> | List of file names. | ||
async |
boolean |
<optional> |
false
|
Indicates that the call should be made async. |
Returns:
The content of the first found file.
- Type
- * | Promise.<*>
loadFirstAsync(files)
Asynchronously load first existing file.
Parameters:
Name | Type | Description |
---|---|---|
files |
Array.<string> | List of the file names. |
Returns:
The content of the first found file.
- Type
- Promise.<*>
loadInFolder(folder, optionsopt, driveropt)
Load all files in folder.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
folder |
string | The folder name. | ||
options |
* |
<optional> |
The options to send during scanning directory. | |
driver |
string | null |
<optional> |
null
|
The driver name to use. If none is provided, the most appropriate driver for each file will be used. |
Returns:
The content fetched for each found file.
- Type
- object.<string, *>
loadRecursivelyInFolder(folder, optionsopt, driveropt)
Load all files in folder recursively.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
folder |
string | The folder name. | ||
options |
* |
<optional> |
The options to send during scanning directory. | |
driver |
string | null |
<optional> |
null
|
The driver name to use. If none is provided, the most appropriate driver for each file will be used. |
Returns:
The content fetched for each found file.
- Type
- object.<string, *>
scandir(folder, typeopt, optionsopt)
Scan directory.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
folder |
string | The folder to scan. | ||
type |
string |
<optional> |
file
|
The type of element we need to find, either "file" or "folder". |
options |
* |
<optional> |
The options to send during scanning directory. |
Returns:
The list of found items in the scanned directory.
- Type
- Array.<string>
write(file, content)
Write given file to a given destination.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | The file path. |
content |
string | The content to write inside the file. |
(async) writeAsync(file, content)
Asynchronously write given file to a given destination.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | The file path. |
content |
string | The content to write inside the file. |
Returns:
The async process promise.
- Type
- Promise
getDriverForFile(file)
Get driver based on file extension.
Parameters:
Name | Type | Description |
---|---|---|
file |
string | The file name. |
Returns:
The best guessed driver instance for the given file name.
driver(nameopt, parametersopt)
- Source:
- Inherited From:
Get loader driver by name.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string |
<optional> |
"default"
|
The driver name. |
parameters |
object |
<optional> |
{}
|
The additional parameters to inject into the driver instance. |
Returns:
The resolved driver instance.
- Type
- object
bootDriver(driver, name)
- Source:
- Inherited From:
Boot newly created driver.
Parameters:
Name | Type | Description |
---|---|---|
driver |
* | The driver instance. |
name |
string | The driver name. |
Returns:
The driver instance.
- Type
- *
addDriver(name, driver)
- Source:
- Inherited From:
Add a driver and bind it with the given name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The driver name. |
driver |
function | The driver class or factory. |
setDefaultDriver(name)
- Source:
- Inherited From:
Set given driver name as the default driver.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The driver name. |
setDriverAlias(name, alias)
- Source:
- Inherited From:
Give driver an alias name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The driver name. |
alias |
string | The driver alias. |
hasDriver(name)
- Source:
- Inherited From:
Check if driver exists.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The driver name. |
Returns:
Indicates that the driver exists.
- Type
- boolean
isDriverAlias(name)
- Source:
- Inherited From:
Check if given driver name is an alias.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The driver alias name. |
Returns:
Indicates that the alias exists.
- Type
- boolean