FILE (interface)
An object representing a file handle.
puts(...strings: Array<string>): void;
}
FILE.target (property)
Human-readable description of where this FILE points.
If target is a number, the FILE was opened with fdopen, and target is
the fd. Otherwise, target will be an arbitrary string that describes the
file; it may be the absolute path to the file, the relative path to the
file at time of its opening, or some other string like "stdin" or
"tmpfile".
You should not use this property for anything other than logging and debugging. It is only provided for debugging and/or troubleshooting purposes. The value of this property could change at any time when upgrading QuickJS or yavascript, even if upgrading by a minor or patch release.
FILE.close (method)
Close the file handle. Note that for files other than stdin/stdout/stderr,
the file will be closed automatically when the FILE object is
garbage-collected.
FILE.puts (method)
Outputs the string with the UTF-8 encoding.
puts(...strings: Array<string>): void;
FILE.printf (method)
Formatted printf.
The same formats as the standard C library printf are supported. Integer format types (e.g. %d) truncate the Numbers or BigInts to 32 bits. Use the l modifier (e.g. %ld) to truncate to 64 bits.
FILE.flush (method)
Flush the buffered file. Wrapper for C fflush.
FILE.sync (method)
Sync the buffered file to disk. Wrapper for C fsync.
FILE.seek (method)
Seek to a given file position (whence is std.SEEK_*).
offset can be a number or a bigint.
FILE.tell (method)
Return the current file position.
FILE.tello (method)
Return the current file position as a bigint.
FILE.eof (method)
Return true if end of file.
FILE.fileno (method)
Return the associated OS handle.
FILE.read (method)
Read length bytes from the file to the ArrayBuffer buffer at byte position position (wrapper to the libc fread). Returns the number of bytes read, or 0 if the end of the file has been reached.
FILE.write (method)
Write length bytes from the ArrayBuffer buffer at byte position position into the file (wrapper to the libc fwrite). Returns the number of bytes written.
FILE.writeTo (method)
Write this file into target, using a memory buffer of size bufferSize.
If limit is specified, only that amount of bytes will be read and
written. Otherwise, data is read and written until this file reaches EOF.
A limit of 0 is treated the same as not specifying a limit.
Internally, this function uses libc fread and fwrite in a loop.
Returns the number of bytes read and written.
FILE.getline (method)
Return the next line from the file, assuming UTF-8 encoding, excluding the trailing line feed or EOF.
If the end of the file has been reached, then null will be returned instead of a string.
Note: Although the trailing line feed has been removed, a carriage return (\r) may still be present.
FILE.readAsString (method)
Read maxSize bytes from the file and return them as a string assuming UTF-8 encoding. If maxSize is not present, the file is read up its end.
FILE.getByte (method)
Return the next byte from the file. Return -1 if the end of file is reached.
FILE.putByte (method)
Write one byte to the file.
FILE.setvbuf (method)
Set the buffering mode and buffer size for the file stream (wrapper to the libc setvbuf()).
Note that unlike the libc setvbuf, the "buffer" argument is not supported, and therefore is not present.
@parammode — The buffering mode to use. It can be one of the following values:std._IOFBFfor full buffering,std._IOLBFfor line buffering, orstd._IONBFfor no buffering.@paramsize — The size to resize the internal in-memory buffer for this file to.
"quickjs:std" (namespace)
export function puts(...strings: Array<string>): void;
export { in_ as in };
[key: string]: string | undefined;
};
}
(url: string): string;
(
url: string,
options: {
binary: false;
},
): string;
(
url: string,
options: {
full: false;
},
): string;
(
url: string,
options: {
binary: false;
full: false;
},
): string;
(
url: string,
options: {
binary: true;
},
): ArrayBuffer;
(
url: string,
options: {
binary: true;
full: false;
},
): ArrayBuffer;
(
url: string,
options: {
full: true;
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
options: {
full: true;
binary: false;
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
options: {
full: true;
binary: true;
},
): {
status: number;
response: ArrayBuffer;
responseHeaders: string;
};
}
maxBytes: number,
format: string,
time: Date | number,
): string;
}
"quickjs:std".loadFile (exported function)
Load the file filename and return it as a string assuming UTF-8 encoding.
@paramfilename — The relative or absolute path to the file to load. Relative paths are resolved relative to the process's current working directory.
"quickjs:std".isFILE (exported function)
Return a boolean indicating whether the provided value is a FILE object.
@paramvalue — The value to check.@returnsWhether the value was aFILEor not.
"quickjs:std".open (exported function)
Open a file (wrapper to the libc fopen()).
Return the FILE object.
@paramfilename — The relative or absolute path to the file to open. Relative paths are resolved relative to the process's current working directory.@paramflags — A string containing any combination of the characters 'r', 'w', 'a', '+', and/or 'b'.@returnsThe opened FILE object.
"quickjs:std".popen (exported function)
Open a process by creating a pipe (wrapper to the libc popen()).
Return the FILE object.
@paramcommand — The command line to execute. Gets passed via/bin/sh -c.@paramflags — A string containing any combination of the characters 'r', 'w', 'a', '+', and/or 'b'.@returnsThe opened FILE object.
"quickjs:std".fdopen (exported function)
Open a file from a file handle (wrapper to the libc fdopen()).
Return the FILE object.
@paramfd — The file handle to open.@paramflags — A string containing any combination of the characters 'r', 'w', 'a', '+', and/or 'b'.@returnsThe opened FILE object.
"quickjs:std".tmpfile (exported function)
Open a temporary file. Return the FILE object.
@returnsThe opened FILE object.
"quickjs:std".puts (exported function)
Equivalent to std.out.puts(str).
export function puts(...strings: Array<string>): void;
"quickjs:std".printf (exported function)
Equivalent to std.out.printf(fmt, ...args)
"quickjs:std".sprintf (exported function)
Equivalent to the libc sprintf().
"quickjs:std".in (exported FILE)
Wrapper to the libc file stdin.
"quickjs:std".in (exported binding)
export { in_ as in };
"quickjs:std".out (exported FILE)
Wrapper to the libc file stdout.
"quickjs:std".err (exported FILE)
Wrapper to the libc file stderr.
"quickjs:std".SEEK_SET (exported number)
Constant for FILE.seek. Declares that pointer offset should be relative to the beginning of the file. See also libc fseek().
"quickjs:std".SEEK_CUR (exported number)
Constant for FILE.seek. Declares that the offset should be relative to the current position of the FILE handle. See also libc fseek().
"quickjs:std".SEEK_END (exported number)
Constant for FILE.seek. Declares that the offset should be relative to the end of the file. See also libc fseek().
"quickjs:std"._IOFBF (exported number)
Constant for FILE.setvbuf. Declares that the buffer mode should be 'full buffering'.
"quickjs:std"._IOLBF (exported number)
Constant for FILE.setvbuf. Declares that the buffer mode should be 'line buffering'.
"quickjs:std"._IONBF (exported number)
Constant for FILE.setvbuf. Declares that the buffer mode should be 'no buffering'.
"quickjs:std".BUFSIZ (exported number)
The default buffer size for a buffered FILE. Useful for passing into FILE.setvbuf.
"quickjs:std".getenv (exported function)
Return the value of the environment variable name or undefined if it is not defined.
"quickjs:std".setenv (exported function)
Set the value of the environment variable name to the string value.
"quickjs:std".unsetenv (exported function)
Delete the environment variable name.
"quickjs:std".getenviron (exported function)
Return an object containing the environment variables as key-value pairs.
[key: string]: string | undefined;
};
"quickjs:std".getuid (exported function)
Return the real user ID of the calling process.
This function throws an error on windows, because windows doesn't support the same uid/gid paradigm as Unix-like operating systems.
"quickjs:std".geteuid (exported function)
Return the effective user ID of the calling process.
This function throws an error on windows, because windows doesn't support the same uid/gid paradigm as Unix-like operating systems.
"quickjs:std".getgid (exported function)
Return the real group ID of the calling process.
This function throws an error on windows, because windows doesn't support the same uid/gid paradigm as Unix-like operating systems.
"quickjs:std".getegid (exported function)
Return the effective group ID of the calling process.
This function throws an error on windows, because windows doesn't support the same uid/gid paradigm as Unix-like operating systems.
"quickjs:std".PasswdEntry (exported interface)
The type of the object returned by getpwuid.
PasswdEntry.name (string property)
PasswdEntry.passwd (string property)
PasswdEntry.uid (number property)
PasswdEntry.gid (number property)
PasswdEntry.gecos (string property)
PasswdEntry.dir (string property)
PasswdEntry.shell (string property)
"quickjs:std".getpwuid (exported function)
Get information from the passwd file entry for the specified user id.
See https://linux.die.net/man/3/getpwuid.
This function throws an error on windows, because windows doesn't support the same uid/gid paradigm as Unix-like operating systems.
"quickjs:std".UrlGet (interface)
(url: string): string;
(
url: string,
options: {
binary: false;
},
): string;
(
url: string,
options: {
full: false;
},
): string;
(
url: string,
options: {
binary: false;
full: false;
},
): string;
(
url: string,
options: {
binary: true;
},
): ArrayBuffer;
(
url: string,
options: {
binary: true;
full: false;
},
): ArrayBuffer;
(
url: string,
options: {
full: true;
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
options: {
full: true;
binary: false;
},
): {
status: number;
response: string;
responseHeaders: string;
};
(
url: string,
options: {
full: true;
binary: true;
},
): {
status: number;
response: ArrayBuffer;
responseHeaders: string;
};
}
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code.
(url: string): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code.
(url: string, options: {
binary: false;
}): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code.
(url: string, options: {
full: false;
}): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns string when
the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code.
(url: string, options: {
binary: false;
full: false;
}): string;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns ArrayBuffer
when the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code.
(url: string, options: {
binary: true;
}): ArrayBuffer;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded). Returns ArrayBuffer
when the http status code is between 200 and 299, and throws otherwise.
Pass an object with { full: true } as the second argument to get response headers and status code.
(url: string, options: {
binary: true;
full: false;
}): ArrayBuffer;
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (string)responseHeaders: headers separated by CRLF (string)status: status code (number)
(url: string, options: {
full: true;
}): {
status: number;
response: string;
responseHeaders: string;
};
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (string)responseHeaders: headers separated by CRLF (string)status: status code (number)
(url: string, options: {
full: true;
binary: false;
}): {
status: number;
response: string;
responseHeaders: string;
};
UrlGet(...) (call signature)
Download url using libcurl (dynamically loaded).
Returns an object with three properties:
response: response body content (ArrayBuffer)responseHeaders: headers separated by CRLF (string)status: status code (number)
(url: string, options: {
full: true;
binary: true;
}): {
status: number;
response: ArrayBuffer;
responseHeaders: string;
};
"quickjs:std".urlGet (exported UrlGet)
"quickjs:std".parseExtJSON (exported function)
Parse str using a superset of JSON.parse. The following extensions are accepted:
- Single line and multiline comments
- unquoted properties (ASCII-only Javascript identifiers)
- trailing comma in array and object definitions
- single quoted strings
\fand\vare accepted as space characters- leading plus in numbers
- octal (0o prefix) and hexadecimal (0x prefix) numbers
"quickjs:std".strftime (exported function)
A wrapper around the standard C strftime. Formats a time/date into a format as specified by the user.
@parammaxBytes — The number of bytes to allocate for the string that will be returned@paramformat — Format string, using%-prefixed sequences as found in this table.@paramtime — The Date object (or unix timestamp, in ms) to render.
maxBytes: number,
format: string,
time: Date | number,
): string;