Utils / DataFile
DataFile Class
Data file retrieval tool
Table of contents
Methods
asyncLoad(fileName : string ): Promise <string > other |
---|
Read Configuration |
exists(fileName : string ): boolean other |
Judge whether the configuration exists |
Methods
asyncLoad
• Static
asyncLoad(fileName
): Promise
<string
> other
Read Configuration
Parameters
fileName string | The file name range of the configuration file: depends on the length of the file name |
---|
Returns
Promise <string > | Configuration content |
---|
Precautions
The configuration file does not exist or the file name is illegal, an empty string will be returned
Usage example: Create a script named 'DataMileExample' and mount it onto an object. The code is as follows:
ts
@Component
export default class DataFileExample extends Script {
protected async onStart(): Promise<void> {
let data = await DataFile.asyncLoad("level2_3");
console.log(`data: ${data}`);
}
}
@Component
export default class DataFileExample extends Script {
protected async onStart(): Promise<void> {
let data = await DataFile.asyncLoad("level2_3");
console.log(`data: ${data}`);
}
}
exists
• Static
exists(fileName
): boolean
other
Judge whether the configuration exists
Parameters
fileName string | The file name range of the configuration file: depends on the length of the file name |
---|
Returns
boolean | Whether the configuration exists |
---|
Precautions
If the file name is invalid, false will be returned. The file name should be a-z, A-Z, 0-9_
Usage example: Create a script named 'DataMileExample' and mount it onto an object. The code is as follows:
ts
@Component
export default class DataFileExample extends Script {
protected onStart(): void {
let exists = DataFile.exist("level2_3");
console.log(`exists: ${exists}`);
}
}
@Component
export default class DataFileExample extends Script {
protected onStart(): void {
let exists = DataFile.exist("level2_3");
console.log(`exists: ${exists}`);
}
}