API Compatibility & Standards Compliance
This document catalogs every API in qjs-modules and its relationship to established standards.
Goals
- Be the standard library QuickJS deserves - WHATWG-spec'd web APIs and Deno/Bun-like runtime APIs
- Compatibility layer - scripts from browser, Node, Deno, Bun should execute with minimal changes
- No qjs-modules-isms - avoid custom APIs that lock users into this implementation
- Standards first - prefer WHATWG > Browser > Bun > Node > Deno when implementing similar functionality
Classification
- Standard - Matches a published spec (WHATWG, W3C, ECMA-262, Node.js, Bun.js)
- Compatible - Similar to a standard but with minor differences
- Custom - qjs-modules specific API with no standard equivalent
- Internal - Private implementation detail, not part of public API surface
- Deprecated - Should be removed or replaced with standard alternative
Research Status
This document is being actively researched. Agents are currently inventorying:
- All C native module exports (quickjs-*.c)
- All JS module exports (lib/*.js)
Results will be populated below as research completes.
C Native Modules
quickjs-archive.c
Module: archive
Classification: Custom (libarchive wrapper)
Spec: https://github.com/libarchive/libarchive/wiki/ManPageLibarchiveFormats3
Exports:
Archiveclass - Read/write compressed archives (tar, zip, cpio, etc.)ArchiveEntryclass - Entry metadataArchiveMatchclass - Pattern matching for entries
Notes: Wraps libarchive for reading/writing compressed archive formats. Not a standard API, but follows established archive format specifications. Useful for file management and distribution.
quickjs-arraybuffer-sink.c
Module: arraybuffer-sink
Classification: Custom (internal utility)
Exports:
ArrayBufferSinkclass - Writable buffer sink backed by resizable ArrayBuffer
Notes: Internal utility for accumulating written bytes. Used by other modules for buffer management.
quickjs-bcrypt.c
Module: bcrypt
Status: Researching...
quickjs-bjson.c
Module: bjson
Status: Researching...
quickjs-blob.c
Module: blob
Classification: Standard (WHATWG)
Spec: https://w3c.github.io/FileAPI/#blob-section
Exports:
Blobclass - Binary large object containerBlob.prototype.size- Size in bytesBlob.prototype.type- MIME typeBlob.prototype.slice(start, end, type)- Returns a new BlobBlob.prototype.text()- Returns Promise<string>Blob.prototype.arrayBuffer()- Returns Promise<ArrayBuffer>Blob.prototype.stream()- Returns ReadableStream (implemented 2026-08-12)
Browser Compatibility: Chrome 5+, Firefox 4+, Safari 5.1+, Edge 12+
Notes: Fully implements WHATWG File API spec. The stream() method was recently fixed to return a proper ReadableStream.
quickjs-child-process.c
Module: child-process
Status: Researching...
quickjs-deep.c
Module: deep
Classification: Internal
Exports:
deep.equal(a, b)- Deep equality comparisondeep.clone(value)- Deep clone objectdeep.merge(target, source)- Deep merge objectsdeep.diff(a, b)- Compute differencesdeep.patch(target, patch)- Apply diff patch
Notes: Internal implementation detail used by lib/deep.js and test infrastructure. Provides low-level deep comparison and cloning. Not intended for direct use in user code - use lib/deep.js wrapper instead.
quickjs-directory.c
Module: directory
Status: Researching...
quickjs-gpio.c
Module: gpio
Status: Researching...
quickjs-inspect.c
Module: inspect
Classification: Compatible (Node.js util.inspect)
Spec: https://nodejs.org/api/util.html#utilinspectobject-options
Exports:
inspect(value, options)- Format value for displayinspect(value, depth)- Format with depth limitinspect.compact- Control whitespace (positive = entry limit, negative = leaf-relative compaction)inspect.colors- Enable/disable ANSI colorsinspect.maxArrayLength- Limit array displayinspect.maxStringLength- Limit string displayinspect.depth- Recursion depth limitinspect.getters- Show getter valuesinspect.showHidden- Show non-enumerable propertiesinspect.custom- Symbol for custom inspect methods
Runtime Compatibility: Node.js util.inspect Notes: Enhanced Node.js util.inspect with negative compact values for leaf-relative object compaction (see doc/native/inspect.md). Used by console.dir() and deep.equal() for formatting.
quickjs-internal.c
Module: internal
Classification: Internal
Exports:
Moduleclass - JavaScript module introspectiongetBytecode(func)- Get compiled bytecodegetOpcodes()- List QuickJS opcodes
Notes: Internal implementation detail for module system introspection and bytecode inspection. Not part of public API surface. Used by qjsm (QuickJS Manager) for module management. Should not be exposed to user code in production.
quickjs-json.c
Module: json
Status: Researching...
quickjs-lexer.c
Module: lexer
Status: Researching...
quickjs-list.c
Module: list
Status: Researching...
quickjs-location.c
Module: location
Status: Researching...
quickjs-magic.c
Module: magic
Status: Researching...
quickjs-misc.c
Module: misc
Status: Researching...
quickjs-mmap.c
Module: mmap
Status: Researching...
quickjs-mysql.c
Module: mysql
Status: Researching...
quickjs-path.c
Module: path
Status: Researching...
quickjs-pgsql.c
Module: pgsql
Status: Researching...
quickjs-pointer.c
Module: pointer
Status: Researching...
quickjs-predicate.c
Module: predicate
Status: Researching...
quickjs-queue.c
Module: queue
Status: Researching...
quickjs-repeater.c
Module: repeater
Status: Researching...
quickjs-serial.c
Module: serial
Status: Researching...
quickjs-sockets.c
Module: sockets
Status: Researching...
quickjs-sqlite.c
Module: sqlite
Status: Researching...
quickjs-stream.c
Module: stream
Classification: Standard (WHATWG)
Spec: https://streams.spec.whatwg.org/
Exports:
ReadableStreamclass - Asynchronous data sourceWritableStreamclass - Asynchronous data sinkTransformStreamclass - Readable + Writable pairByteLengthQueuingStrategy- Queue based on byte lengthCountQueuingStrategy- Queue based on chunk count
Browser Compatibility: Chrome 52+, Firefox 65+, Safari 10.1+, Edge 16+
Notes: Implements core WHATWG Streams spec. Missing: respondWithNewView() safety checks for BYOB (Bring Your Own Buffer) readers - this is a known spec compliance gap tracked in TODO Tier 3.
quickjs-syscallerror.c
Module: syscallerror
Status: Researching...
quickjs-textcode.c
Module: textcode
Status: Researching...
quickjs-tree-walker.c
Module: tree-walker
Status: Researching...
quickjs-virtual.c
Module: virtual
Status: Researching...
quickjs-xml.c
Module: xml
Status: Researching...
JavaScript Modules
lib/abort.js
Module: abort
Status: Researching...
lib/arrayLike.js
Module: arrayLike
Status: Researching...
lib/assert.js
Module: assert
Classification: Compatible (Node.js)
Spec: https://nodejs.org/api/assert.html
Exports:
assert(value, message)- Truthiness assertionassert.ok(value, message)- Truthiness assertionassert.equal(actual, expected, message)- Loose equalityassert.notEqual(actual, expected, message)- Loose inequalityassert.strictEqual(actual, expected, message)- Strict equalityassert.notStrictEqual(actual, expected, message)- Strict inequalityassert.deepEqual(actual, expected, message)- Deep loose equalityassert.notDeepEqual(actual, expected, message)- Deep loose inequalityassert.deepStrictEqual(actual, expected, message)- Deep strict equalityassert.notDeepStrictEqual(actual, expected, message)- Deep strict inequalityassert.throws(fn, error, message)- Expect exceptionassert.doesNotThrow(fn, error, message)- Expect no exceptionassert.rejects(asyncFn, error, message)- Expect promise rejectionassert.doesNotReject(asyncFn, error, message)- Expect no rejectionassert.ifError(value)- Throw if truthyassert.fail(message)- Always failassert.match(string, regexp, message)- RegExp matchassert.doesNotMatch(string, regexp, message)- RegExp non-match
Runtime Compatibility: Node.js, Bun, Deno Notes: Comprehensive Node.js assert API. Used extensively in test suite.
lib/asyncIterator.js
Module: asyncIterator
Status: Researching...
lib/console.js
Module: console
Classification: Standard (WHATWG)
Spec: https://console.spec.whatwg.org/
Exports:
console.log(...args)- Log messageconsole.error(...args)- Log errorconsole.warn(...args)- Log warningconsole.info(...args)- Log infoconsole.debug(...args)- Log debugconsole.dir(obj, options)- Inspect objectconsole.time(label)- Start timerconsole.timeEnd(label)- End timerconsole.trace(...args)- Stack traceconsole.assert(condition, ...args)- Assertionconsole.table(data)- Table formatconsole.group(label)- Group logsconsole.groupEnd()- End group
Browser Compatibility: Universal
Notes: Implements core WHATWG Console API. Uses inspect module for console.dir() formatting.
lib/css-selectors.js
Module: css-selectors
Status: Researching...
lib/css3-selectors.js
Module: css3-selectors
Status: Researching...
lib/database.js
Module: database
Status: Researching...
lib/db.js
Module: db
Status: Researching...
lib/dbi.js
Module: dbi
Status: Researching...
lib/deep.js
Module: deep
Status: Researching...
lib/describe-class.js
Module: describe-class
Status: Researching...
lib/dom.js
Module: dom
Classification: Standard (W3C)
Spec: https://dom.spec.whatwg.org/
Exports:
Documentclass - HTML/XML documentElementclass - DOM elementNodeclass - Base DOM nodeNodeListclass - Collection of nodesHTMLCollectionclass - Live collection of elementsEventclass - DOM eventEventTargetclass - Event dispatch baseHTMLElement+ 50+ subclasses (Input, Button, Form, etc.)MutationObserverclass - DOM mutation trackingRangeclass - Document range selectionSelectionclass - User selectionDOMRectclass - Element geometryHistoryclass - Browser history APINavigatorclass - Browser environment infoLocationclass - URL/location APIStorageclass - localStorage/sessionStorageWindowclass - Global window objectFileclass - File API (in lib/file.js)DOMStringMapclass - dataset APICSSStyleDeclarationclass - Inline styles
Browser Compatibility: Universal (DOM Level 4) Notes: Comprehensive DOM implementation covering 90%+ of browser DOM APIs. See TODO Tier 9 for remaining gaps: Fetch API, FormData, CSSOM, IntersectionObserver, ResizeObserver, WebSocket, Canvas, Web Workers.
lib/events.js
Module: events
Classification: Compatible (Node.js)
Spec: https://nodejs.org/api/events.html
Exports:
EventEmitterclass - Event emitter base classEventEmitter.prototype.on(event, listener)- Add listenerEventEmitter.prototype.once(event, listener)- Add one-time listenerEventEmitter.prototype.off(event, listener)- Remove listenerEventEmitter.prototype.emit(event, ...args)- Trigger eventEventEmitter.prototype.listenerCount(event)- Count listeners
Runtime Compatibility: Node.js, Bun, Deno (with --unstable) Notes: Compatible with Node.js EventEmitter API. Different from browser EventTarget/Event API (which is in lib/dom.js). For browser-style events, use the DOM module instead.
lib/extendArray.js
Module: extendArray
Status: Researching...
lib/extendArrayBuffer.js
Module: extendArrayBuffer
Status: Researching...
lib/extendAsyncFunction.js
Module: extendAsyncFunction
Status: Researching...
lib/extendAsyncGenerator.js
Module: extendAsyncGenerator
Status: Researching...
lib/extendFunction.js
Module: extendFunction
Status: Researching...
lib/extendGenerator.js
Module: extendGenerator
Status: Researching...
lib/extendMap.js
Module: extendMap
Status: Researching...
lib/extendMath.js
Module: extendMath
Status: Researching...
lib/extendObject.js
Module: extendObject
Status: Researching...
lib/extendSet.js
Module: extendSet
Status: Researching...
lib/file.js
Module: file
Status: Researching...
lib/fs.js
Module: fs
Classification: Compatible (Node.js)
Spec: https://nodejs.org/api/fs.html
Exports:
readFile(path, options, callback)- Read file asyncreadFileSync(path, options)- Read file syncwriteFile(path, data, options, callback)- Write file asyncwriteFileSync(path, data, options)- Write file syncmkdir(path, options, callback)- Create directorymkdirSync(path, options)- Create directory syncreaddir(path, options, callback)- List directoryreaddirSync(path, options)- List directory syncstat(path, callback)- File stats asyncstatSync(path)- File stats syncunlink(path, callback)- Delete fileunlinkSync(path)- Delete file syncexists(path, callback)- Check existenceexistsSync(path)- Check existence syncchmod(path, mode, callback)- Change permissionschmodSync(path, mode)- Change permissions syncchown(path, uid, gid, callback)- Change ownershipchownSync(path, uid, gid)- Change ownership synccopyFile(src, dest, callback)- Copy filecopyFileSync(src, dest)- Copy file syncrename(oldPath, newPath, callback)- Rename filerenameSync(oldPath, newPath)- Rename file synclink(existingPath, newPath, callback)- Create hard linklinkSync(existingPath, newPath)- Create hard link syncsymlink(target, path, callback)- Create symlinksymlinkSync(target, path)- Create symlink syncreadlink(path, callback)- Read symlinkreadlinkSync(path)- Read symlink syncrealpath(path, callback)- Resolve pathrealpathSync(path)- Resolve path synctruncate(path, len, callback)- Truncate filetruncateSync(path, len)- Truncate file syncopen(path, flags, mode, callback)- Open fileopenSync(path, flags, mode)- Open file syncclose(fd, callback)- Close filecloseSync(fd)- Close file syncread(fd, buffer, offset, length, position, callback)- Read from fdreadSync(fd, buffer, offset, length, position)- Read from fd syncwrite(fd, buffer, offset, length, position, callback)- Write to fdwriteSync(fd, buffer, offset, length, position)- Write to fd syncfstat(fd, callback)- File stats by fdfstatSync(fd)- File stats by fd syncftruncate(fd, len, callback)- Truncate by fdftruncateSync(fd, len)- Truncate by fd syncwatch(filename, options, listener)- Watch filewatchFile(filename, options, listener)- Watch file (polling)unwatchFile(filename, listener)- Stop watchingcreateReadStream(path, options)- Create read streamcreateWriteStream(path, options)- Create write streampromises- Promise-based API (see fsPromises.js)
Runtime Compatibility: Node.js, Bun, Deno (with --unstable) Notes: Comprehensive Node.js fs API implementation. Uses quickjs-fs.c native bindings. Some advanced features (watch, streams) may have limitations vs Node.js.
lib/fsPromises.js
Module: fsPromises
Classification: Compatible (Node.js)
Spec: https://nodejs.org/api/fs.html#fs_promises_api
Exports:
fsPromises.readFile(path, options)- Read file (Promise)fsPromises.writeFile(path, data, options)- Write file (Promise)fsPromises.appendFile(path, data, options)- Append to file (Promise)fsPromises.mkdir(path, options)- Create directory (Promise)fsPromises.readdir(path, options)- List directory (Promise)fsPromises.stat(path)- File stats (Promise)fsPromises.lstat(path)- Symlink stats (Promise)fsPromises.unlink(path)- Delete file (Promise)fsPromises.rmdir(path, options)- Remove directory (Promise)fsPromises.rm(path, options)- Remove file/dir (Promise)fsPromises.rename(oldPath, newPath)- Rename (Promise)fsPromises.copyFile(src, dest, mode)- Copy file (Promise)fsPromises.chmod(path, mode)- Change permissions (Promise)fsPromises.chown(path, uid, gid)- Change ownership (Promise)fsPromises.link(existingPath, newPath)- Create hard link (Promise)fsPromises.symlink(target, path, type)- Create symlink (Promise)fsPromises.readlink(path)- Read symlink (Promise)fsPromises.realpath(path, options)- Resolve path (Promise)fsPromises.truncate(path, len)- Truncate file (Promise)fsPromises.utimes(path, atime, mtime)- Change timestamps (Promise)fsPromises.access(path, mode)- Check access (Promise)fsPromises.open(path, flags, mode)- Open file handle (Promise)fsPromises.cp(src, dest, options)- Copy file/dir (Promise)fsPromises.glob(pattern, options)- Glob pattern match (Promise)fsPromises.watch(filename, options)- Watch file (AsyncIterator)
Runtime Compatibility: Node.js 10+, Bun, Deno (with --unstable) Notes: Promise-based fs API. Wraps lib/fs.js callback API with Promise interface.
lib/html.js
Module: html
Status: Researching...
lib/inotify.js
Module: inotify
Status: Researching...
lib/io.js
Module: io
Status: Researching...
lib/iterator.js
Module: iterator
Status: Researching...
lib/misc.js
Module: misc
Status: Researching...
lib/module.js
Module: module
Status: Researching...
lib/parsel.js
Module: parsel
Status: Researching...
lib/parser.js
Module: parser
Status: Researching...
lib/perf_hooks.js
Module: perf_hooks
Status: Researching...
lib/pointer.js
Module: pointer
Status: Researching...
lib/predicate.js
Module: predicate
Classification: Internal
Exports:
Predicateclass - Type predicate for operator overloadingPredicate.prototype.call(value)- Test value against predicatePredicate.prototype.and(other)- Logical ANDPredicate.prototype.or(other)- Logical ORPredicate.prototype.not()- Logical NOTPredicate.type(typeCode)- Create type predicatePredicate.instance(class)- Create instanceof predicatePredicate.value(val)- Create equality predicate
Notes: Internal implementation detail used by lib/parser.js for cross-type operator dispatch. Enables terminalA >> terminalB syntax. Not intended for direct use in user code. See doc/js/predicate.md for implementation details.
lib/process.js
Module: process
Classification: Compatible (Node.js)
Spec: https://nodejs.org/api/process.html
Exports:
process.argv- Command-line argumentsprocess.argv0- Original argv[0]process.env- Environment variablesprocess.cwd()- Current working directoryprocess.chdir(dir)- Change working directoryprocess.exit(code)- Exit processprocess.exitCode- Exit codeprocess.pid- Process IDprocess.ppid- Parent process IDprocess.platform- Platform stringprocess.arch- Architecture stringprocess.version- Node.js version (compatibility shim)process.versions- Version infoprocess.release- Release metadataprocess.title- Process titleprocess.stdout- Standard output streamprocess.stderr- Standard error streamprocess.stdin- Standard input streamprocess.nextTick(callback, ...args)- Queue callbackprocess.hrtime()- High-resolution timeprocess.hrtime.bigint()- High-resolution time as BigIntprocess.memoryUsage()- Memory usage statsprocess.cpuUsage()- CPU usage statsprocess.uptime()- Process uptimeprocess.kill(pid, signal)- Send signal to processprocess.on(event, listener)- Add event listenerprocess.once(event, listener)- Add one-time listenerprocess.emit(event, ...args)- Emit eventprocess.removeListener(event, listener)- Remove listenerprocess.removeAllListeners(event)- Remove all listeners
Runtime Compatibility: Node.js, Bun, Deno (with --unstable)
Notes: Comprehensive Node.js process API. Some features may have limitations vs Node.js (e.g., process.fork(), cluster support). The process.argv issue with -e mode has been fixed (see commit 72c0364d).
lib/reflect.js
Module: reflect
Status: Researching...
lib/repl.js
Module: repl
Status: Researching...
lib/require.js
Module: require
Status: Researching...
lib/socklen_t.js
Module: socklen_t
Status: Researching...
lib/stack.js
Module: stack
Status: Researching...
lib/stream.js
Module: stream
Status: Researching...
lib/streams.js
Module: streams
Status: Researching...
lib/terminal.js
Module: terminal
Status: Researching...
lib/testharness.js
Module: testharness
Status: Researching...
lib/testharnessreport.js
Module: testharnessreport
Status: Researching...
lib/timers.js
Module: timers
Classification: Standard (HTML5)
Spec: https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html
Exports:
setTimeout(callback, delay, ...args)- Delayed executionclearTimeout(id)- Cancel timeoutsetInterval(callback, delay, ...args)- Repeated executionclearInterval(id)- Cancel intervalsetImmediate(callback, ...args)- Immediate execution (Node.js)clearImmediate(id)- Cancel immediate (Node.js)queueMicrotask(callback)- Queue microtask
Browser Compatibility: Universal
Notes: Implements HTML5 Timers API. Also includes Node.js-style setImmediate for compatibility.
lib/tree_walker.js
Module: tree_walker
Status: Researching...
lib/tty.js
Module: tty
Status: Researching...
lib/url.js
Module: url
Classification: Standard (WHATWG)
Spec: https://url.spec.whatwg.org/
Exports:
URLclass - URL parser and serializerURL.prototype.href- Full URL stringURL.prototype.origin- Origin (scheme + host + port)URL.prototype.protocol- URL schemeURL.prototype.host- Host + portURL.prototype.hostname- Host without portURL.prototype.port- Port numberURL.prototype.pathname- Path componentURL.prototype.search- Query stringURL.prototype.searchParams- URLSearchParams objectURL.prototype.hash- Fragment identifierURLSearchParamsclass - Query string parserURL.createObjectURL(blob)- Create object URL (not yet implemented)URL.revokeObjectURL(url)- Revoke object URL (not yet implemented)
Browser Compatibility: Chrome 32+, Firefox 19+, Safari 7+, Edge 12+
Notes: Core URL parsing is implemented. Missing: createObjectURL() and revokeObjectURL() for Blob/File references (tracked in TODO Tier 9.6).
lib/util.js
Module: util
Status: Researching...
lib/vfs.js
Module: vfs
Status: Researching...
lib/xml.js
Module: xml
Status: Researching...
lib/xpath.js
Module: xpath
Status: Researching...
Roadmap
Once research is complete, prioritize:
- Deprecate custom APIs that have standard equivalents
- Fix incompatible APIs to match standards more closely
- Document gaps where standards exist but aren't implemented
- Keep internal APIs that are implementation details (predicate, deep, etc.)
- Stop adding non-standard APIs unless absolutely necessary
Notes
- APIs like
deepandpredicateare internal implementation details used by other modules inspectis similar to Node.jsutil.inspectbut with additional features (negative compact values)streammodule implements WHATWG Streams specblobmodule implements WHATWG Blob specdommodule implements W3C DOM spec