Skip to content

Latest commit

 

History

History
372 lines (227 loc) · 10.8 KB

API.md

File metadata and controls

372 lines (227 loc) · 10.8 KB

API documentation

Note

The long term goal for LLRT is to become Winter CG compliant. Not every API from Node.js will be supported.

buffer

alloc

byteLength

concat

from

Everything else inherited from Uint8Array

child_process

Warning

spawn uses native streams that is not 100% compatible with the Node.js Streams API.

spawn

console

Console

crypto

createHash

createHmac

getRandomValues

randomBytes

randomFill

randomFillSync

randomInt

randomUUID

events

EventEmitter

fetch

Available globally

fetch

Important

There are some differences with the WHATWG standard. Mainly browser specific behavior is removed:

  • keepalive is always true
  • request.body can only be string, Array, ArrayBuffer or Uint8Array
  • response.body returns null. Use response.text(), response.json() etc
  • mode, credentials, referrerPolicy, priority, cache is not available/applicable

file

file

fs

accessSync

mkdirSync

mkdtempSync

readdirSync

readFileSync

rmdirSync

rmSync

statSync

writeFileSync

fs/promises

access

constants

mkdir

mkdtemp

readdir

readFile

rm

rmdir

stat

writeFile

module

createRequire

Note

require is available from esm modules natively. This function is just for compatibility

net

Warning

These APIs uses native streams that is not 100% compatible with the Node.js Streams API. Server APIs like createSever provides limited functionality useful for testing purposes. Serverless applications typically don't expose servers. Some server options are not supported: highWaterMark, pauseOnConnect, keepAlive, noDelay, keepAliveInitialDelay

connect

createConnection

createServer

os

platform

release

tmpdir

type

path

basename

delimiter

dirname

extname

format

isAbsolute

join

normalize

parse

resolve

timers

Also available globally

clearImmediate

clearInterval

clearTimeout

setImmediate

setInterval

setTimeout

url

export class URL {
  constructor(input: string, base?: string | URL);

  hash: string;
  host: string;
  hostname: string;
  href: string;
  origin: string;
  password: string;
  pathname: string;
  port: string;
  protocol: string;
  search: string;
  searchParams: URLSearchParams;
  username: string;

  parse(input: string, base?: string): URL | null;
  canParse(input: string, base?: string): boolean;
  toJSON(): string;
  toString(): string;
}
// Additional utilities in the URL module
export function domainToASCII(domain: string): string;

export function domainToUnicode(domain: string): string;

export function fileURLToPath(url: string | URL): string;

export function pathToFileURL(path: string): URL;

export function format(url: string | URL, options?: { fragment?: boolean, unicode?: boolean, auth?: boolean
}): string;

export function urlToHttpOptions(url: URL): {
  protocol?: string;
  hostname?: string;
  port?: string;
  path?: string;
  ...
};

URLSearchParams

export class URLSearchParams {
  constructor(
    init?: string | string[][] | Record<string, string> | URLSearchParams
  );

  // properties
  size: number;

  // Methods
  append(name: string, value: string): void;
  delete(name: string): void;
  get(name: string): string | null;
  getAll(name: string): string[];
  has(name: string): boolean;
  set(name: string, value: string): void;
  sort(): void;

  [Symbol.iterator](): IterableIterator<[string, string]>;
  entries(): IterableIterator<[string, string]>;
  forEach(): IterableIterator<[string, string]>;
  keys(): IterableIterator<string>;
  values(): IterableIterator<string>;

  toString(): string;
}

util

Important

Supported encodings: hex, base64, utf-8, utf-16le, windows-1252 and their aliases.

TextDecoder

TextEncoder

zlib

deflate

deflateSync

deflateRaw

deflateRawSync

gzip

gzipSync

inflate

inflateSync

inflateRaw

inflateRawSync

gunzip

gunzipSync

brotliCompress

brotliCompressSync

brotliDecompress

brotliDecompressSync

llrt:hex

export function encode(
  value: string | Array | ArrayBuffer | Uint8Array
): string;
export function decode(value: string): Uint8Array;

llrt:uuid

export const NIL: string;

export function v1(): string;

export function v3(
  name: string,
  namespace: Array | Uint8Array | String
): string;

export function v4(): string;

export function v5(
  name: string,
  namespace: Array | Uint8Array | String
): string;

export function parse(value: string): Uint8Array;

export function stringify(arr: Array | Uint8Array): string;

export function validate(arr: string): boolean;

export function version(arr: Array | Uint8Array): number;

llrt:xml

A lightweight and fast XML parser

type XmlParserOptions = {
    ignoreAttributes?: boolean;
    attributeNamePrefix?: string;
    textNodeName?: string;
    attributeValueProcessor?: (attrName: string, attrValue: string, jpath: string) => unknown;
    tagValueProcessor?: (attrName: string, attrValue: string, jpath: string, hasAttributes: boolean) => unknown;
}
export class XMLParser(options?: XmlParserOptions){
    parse(xml:string):object
}

Misc Global objects

AbortController

AbortSignal

atob

btoa

DOMException

navigator.userAgent

performance.now

performance.timeOrigin

structuredClone