Other Utilities
mount
Mount a file system
function mount(codeHash: ArrayBuffer, hashType: number): void;
Parameters
codeHash
: The code hash of the Cell to mount.hashType
: The hash type of the code (use SCRIPTHASH_TYPE* constants).
evalJsScript
Evaluate a JavaScript Script (Generally used before loadJsScript
).
function evalJsScript(jsScript: string, enableModule?: boolean): any;
Parameters
jsScript
: The JavaScript Script to evaluateenableModule
: Whether to enable ES6 module (default: false)
Return
- The result of the Script evaluation. When
enableModule
is true, the Script doesn't return any value.
loadJsScript
Load a JavaScript Script
function loadJsScript(path: string, enableModule?: boolean): any;
Parameters
path
: The path to the JavaScript ScriptenableModule
: Whether to enable ES6 module (default: false)
Return
- The loaded Script as ArrayBuffer.
- When
enableModule
is true, the Script doesn't return any value.
loadFile
Load a file
function loadFile(path: string): string;
Parameters
path
: The path to the file
Return
string
: The loaded file as a string
debug
Output a debug message.
function debug(message: string): void;
Parameters
message
: The debug message to output
note
While calling debug
directly may offer better performance, using console
is generally recommended unless you are in a highly performance-sensitive situation.
sprintf
Format and return a string using printf-style formatting
function sprintf(format: string, ...args: any[]): string;
Parameters
format
: Printf format stringargs
: Values to format
Return
string
: The formatted string
printf
Format and print a string using printf-style formatting
function printf(format: string, ...args: any[]): void;
Parameters
format
: Printf format stringargs
: Values to format
console
Console object for logging and assertions.
export const console: {
log(...args: any[]): void;
assert(condition: boolean, ...args: any[]): void;
};