pub fn parse_async_raw(
filename: String,
buffer: Uint8Array,
source_len: u32,
options: Option<ParserOptions>,
) -> AsyncTask<ResolveTask>Expand description
Parse AST into provided Uint8Array buffer, asynchronously.
Note: This function can be slower than parseSyncRaw due to the overhead of spawning a thread.
Source text must be written into the start of the buffer, and its length (in UTF-8 bytes)
provided as source_len.
This function will parse the source, and write the AST into the buffer, starting at the end.
It also writes to the very end of the buffer the offset of Program within the buffer.
Caller can deserialize data from the buffer on JS side.
§SAFETY
Caller must ensure:
- Source text is written into start of the buffer.
- Source text’s UTF-8 byte length is
source_len. - The 1st
source_lenbytes of the buffer comprises a valid UTF-8 string. - Contents of buffer must not be mutated by caller until the
AsyncTaskreturned by this function resolves.
If source text is originally a JS string on JS side, and converted to a buffer with
Buffer.from(str) or new TextEncoder().encode(str), this guarantees it’s valid UTF-8.
§Panics
Panics if source text is too long, or AST takes more memory than is available in the buffer.