Modules (require)
Load a module with require('name'). NodeAmiga looks up modules in this order:
- Built-in native modules (implemented in C inside NodeAmiga)
- Embedded bundle (when running from a
-compile'd standalone executable) - Relative path (
./file.js/../file.js) - Absolute AmigaOS path (anything containing
:, e.g.SYS:libs/foo.js) - Search path:
PROGDIR:libs/,LIBS:node/,libs/,PROGDIR:modules/, current dir — tries bothname.jsandname/index.js
ES-module syntax (import / export) is also supported and uses the same resolution logic.
Modules on this page
- fs — files & directories
- http — HTTP client & server
- net — raw TCP (alias of http)
- buffer — binary data
- os — system info
- path — path manipulation
- url — URL parsing
- querystring
- events — EventEmitter
- stream
- util
- assert
- zlib
- crypto
- readline
- dns
- timers (promise-based)
- string_decoder
- punycode
- console, constants
- iff — IFF/ILBM/8SVX parser
- child_process
- gui — GadTools widget toolkit
- intuition — low-level windows
- clipboard
- arexx
- amiga — FFI (call any library)
fs — files & directories
var fs = require('fs');
Synchronous filesystem via AmigaOS DOS. All operations take
AmigaOS-style paths (RAM:foo.txt, SYS:s/startup-sequence).
Returns the file contents. With encoding: 'utf8' returns a string; otherwise a Buffer.
Write a string or Buffer to disk. Overwrites existing files.
Append to an existing file (or create).
Delete a file.
Returns {size, isFile(), isDirectory()}. Throws Error with ENOENT if the path doesn't exist.
Returns an array of entry names (no . / ..). Uses Lock+Examine+ExNext.
4 KB buffered copy.
Callback-style versions. Still synchronous internally on Amiga — the callback runs before the call returns. Useful for Node.js portability.
Returns an EventEmitter emitting 'data' (Buffers) and 'end'. Note: reads the whole file in one sweep — highWaterMark only chooses chunk size for the emitted data events.
EventEmitter with write(chunk), end(), 'finish' event, bytesWritten.
RAM: is your friend
The Amiga RAM disk (RAM:) is blazing fast and perfect for temp files, caches, and small databases. Use it freely for anything that doesn't need to survive a reboot.
http — HTTP client & server
var http = require('http');
HTTP/1.0 client and server over bsdsocket.library. HTTPS
requires AmiSSL (see below).
Client
Synchronous GET. Follows up to 5 redirects automatically (301/302/303/307/308). Body is always a string.
Synchronous POST. body is a string or Buffer. Default content type: application/x-www-form-urlencoded.
Generic request. options may be {url, method, body, headers}.
Server
Create a server. handler(req, res) is called for each request.
Start accepting connections. Handles up to 8 concurrent clients (non-blocking via WaitSelect). Stops on Ctrl+C.
In the handler:
req.method,req.url,req.headers(object),req.body(string)res.writeHead(status, headers),res.write(chunk),res.end(chunk?)
HTTPS / AmiSSL
Returns true if HTTPS is available at runtime. Requires NodeAmiga built with -DENABLE_AMISSL AND AmiSSL 5+ installed on the system.
10-second socket timeout
Both send and receive have a 10-second timeout. Slow or unresponsive servers will fail with a connection error. There's currently no way to override this from JavaScript.
net — raw TCP
Currently exposes the same get/request/createServer as http. For a dedicated low-level TCP API, use the FFI module to call bsdsocket.library directly.
buffer
var { Buffer } = require('buffer'); // also available as global
Same Buffer as described in Global API → Buffer. The module export additionally provides Buffer as a named property for Node.js portability.
os — system info
var os = require('os');
Kickstart version from ExecBase->lib_Version.
Available memory, from AvailMem(MEMF_ANY).
Returns the same value as freemem() — AmigaOS 2.x has no API for the total installed memory.
Returns a single-element array [{ model, speed }]. Model comes from SysBase->AttnFlags (68000/68010/68020/68030/68040/68060). Speed is always 0 (no portable way to read accelerator clock).
Not implemented; AmigaOS has no portable uptime API.
Hardcoded: {username:"amiga", uid:-1, gid:-1, homedir:"SYS:", shell:""}.
Empty — TCP/IP stacks differ; NodeAmiga doesn't enumerate them.
Constants: os.EOL = "\n", os.devNull = "NIL:", os.constants.signals.SIGINT=2, os.constants.signals.SIGTERM=15.
path — path manipulation
var path = require('path');
Uses AmigaOS conventions: absolute paths contain :
(e.g. SYS:foo/bar), relative don't.
Last segment. Optional ext strips trailing extension.
Everything except the last segment.
The .ext part (or empty string).
Concatenate with /. Any part containing : resets the accumulator.
Like join but always produces an absolute-looking result.
Collapse .. and ..
Returns true if p contains a colon (Amiga absolute).
Constants: path.sep = '/', path.delimiter = ';'.
url — URL parsing
var url = require('url');
Legacy API
Returns {protocol, slashes, auth, hostname, port, host, pathname, search, query, hash, path, href}. With parseQueryString=true, query is a parsed object (via querystring.parse).
Rebuilds a URL string from a parse result.
Resolve a relative URL against a base.
WHATWG URL
Modern URL class. .protocol, .hostname, .port, .pathname, .search, .hash, .host, .origin, .href, .username, .password, .searchParams, .toString(), .toJSON().
Does NOT throw on invalid input — it parses permissively and returns a partial object (spec-divergent).
append, delete, get, getAll, has, set, sort, toString, forEach, keys, values, entries, .size. Note: keys/values/entries return arrays, not iterators.
querystring
var qs = require('querystring');
Standard Node.js querystring semantics: repeated keys become arrays on parse; arrays produce multiple key=value pairs on stringify.
events — EventEmitter
var EventEmitter = require('events');
var bus = new EventEmitter();
bus.on('ready', () => console.log('go!'));
bus.emit('ready');
Methods: on(event, fn), off(event, fn), once(event, fn), emit(event, ...args), removeListener, removeAllListeners(event?), listenerCount(event), listeners(event), setMaxListeners(n), eventNames(), prependListener, prependOnceListener. Aliases: addListener = on.
Emit passes up to 5 args
emit(event, a, b, c, d, e) passes the first five arguments to each listener. Beyond that, arguments are discarded. (Node.js has no such limit.)
stream
var stream = require('stream');
Pure-JS implementations of Readable, Writable, Duplex, Transform, PassThrough, plus helpers pipeline(...streams, cb) and finished(stream, cb).
var r = new stream.Readable({ read() {} });
r.on('data', chunk => console.log(chunk));
r.push('hello');
r.push(null); // end
Supports pipe(dest), backpressure, highWaterMark (default 16), cork/uncork on Writable.
util
var util = require('util');
printf-style formatter. Supports %s, %d, %i, %f, %j (JSON), %o/%O (inspect), %%.
Pretty-print an object for debugging. Default depth 2. Truncates arrays at 100 items, objects at 50 keys.
Classic pre-ES6 inheritance helper.
Converts a Node-style (err, result) → callback function.
Legacy type predicates: util.isArray/isFunction/isString/isNumber/isBoolean/isNull/isUndefined/isNullOrUndefined/isObject/isPrimitive.
Also: util.noop, util.debuglog(section) (currently returns a no-op).
assert
var assert = require('assert');
assert(x > 0, 'x must be positive');
Methods: assert.ok, assert.equal/notEqual, strictEqual/notStrictEqual, deepEqual/notDeepEqual, deepStrictEqual/notDeepStrictEqual, throws(fn, expected?, msg?), doesNotThrow, fail(msg), ifError(err), match(str, re, msg?), doesNotMatch, rejects(p), doesNotReject(p).
The callable module itself behaves as assert.ok.
deepEqual is strict
assert.deepEqual currently uses the same comparator as deepStrictEqual. It won't coerce 1 == "1" to true. Use assert.equal for loose equality.
zlib
var zlib = require('zlib');
Compress and decompress data. Input and output are strings (cast bytes through Buffer.from/toString if you need Buffers).
deflate does not actually compress
The encoder currently emits "stored" (uncompressed) DEFLATE blocks — the output is larger than the input. The decoder handles fully compressed streams correctly, so this module is useful for reading gzip/deflate data but not for producing it compactly.
crypto
var crypto = require('crypto');
var hash = crypto.createHash('sha256').update('hello').digest('hex');
Supported: 'md5' (RFC 1321), 'sha256' (FIPS 180-4). Default if omitted: sha256.
The hasher has update(data) (returns this, chainable) and digest(encoding?). Only 'hex' encoding is supported — the encoding argument is accepted but ignored for other values.
No HMAC, no ciphers — plain hash functions only.
readline
var readline = require('readline');
var rl = readline.createInterface({ prompt: '> ' });
rl.question('Name? ', name => { console.log('Hi '+name); rl.close(); });
Interface methods: question(prompt, cb), prompt(), setPrompt(str), close(), on('line', fn), on('close', fn).
No line-editing (cursor keys, history) in this module — those work in the REPL via process.stdin at a lower level. Use it for simple input prompts.
dns
var dns = require('dns');
callback(err, address). Resolves a single IPv4 address.
Returns an array of IPv4 addresses via callback.
Sync version. Returns empty array if no records.
Under the hood, all of these call inet_addr/gethostbyname; the async signatures are for Node.js portability — the resolution is synchronous, the callback fires immediately.
timers (promise-based)
var timers = require('timers/promises'); // or just 'timers'
await timers.setTimeout(500, 'done');
Returns a Promise that resolves to value after delay ms.
Alias for setTimeout(0, value).
Returns an async-iterable-like with next(), cancel(), and a then() for one-shot waiting.
string_decoder
var { StringDecoder } = require('string_decoder');
Converts Buffers to strings while handling multi-byte UTF-8 boundaries. Useful when reading a stream chunk by chunk.
new StringDecoder(encoding?) — default 'utf8'. Methods: write(buf), end(buf?). Incomplete trailing bytes are buffered internally and surfaced as a replacement character \uFFFD on end() if they never complete.
punycode
var punycode = require('punycode');
punycode.toASCII('münchen.de'); // 'xn--mnchen-3ya.de'
RFC 3492 IDN encoder/decoder: encode, decode, toASCII, toUnicode, plus ucs2.decode/ucs2.encode.
console (module), constants
var c = require('console'); // same as global console
var K = require('constants'); // POSIX errno & signal names
require('console') simply re-exports the global console object.
require('constants') exposes POSIX-ish numeric codes: signals (SIGTERM=15, ...), errno (ENOENT=2, ...), fs constants (O_RDONLY=0, O_CREAT=64, ...). Values follow BSD conventions, not Amiga IoErr codes — use them for code portability, not for comparing against actual AmigaDOS errors.
iff — IFF/ILBM/8SVX parser
var iff = require('iff');
var img = iff.parseILBM(iff.parseFile('RAM:pic.iff'));
Pure-JS parser for Amiga's native Interchange File Format. Handles ILBM images and 8SVX audio in particular.
Returns a tree: {type, subType, length, chunks: [...]}. Each chunk has id, length, offset, data (array of bytes), and optionally nested chunks for FORM/LIST/CAT.
Depth-first chunk search.
Parse an ILBM bitmap header.
Parse a color palette.
Decode an ILBM all the way to chunky pixel indices. Handles ByteRun1 RLE decompression. Slow in pure JS for large images.
Low-level access to the RLE decompression routine.
child_process
var cp = require('child_process');
var out = cp.execSync('version');
Runs an AmigaOS command via SystemTagList, captures stdout via T:nodeamiga_exec_tmp, returns as a string.
Same as execSync with callback(null, stdout, stderr). stderr is always an empty string — capturing it reliably on AmigaOS is non-trivial.
gui — GadTools widget toolkit
var gui = require('gui');
var win = gui.createWindow({ title: 'Demo', width: 300, height: 150,
gadgets: [{ kind: 'button', id: 1, label: 'Click me',
left: 10, top: 10, width: 100, height: 14 }]});
while (true) {
var evt = gui.waitEvent(win);
if (evt.type === 'close') break;
if (evt.type === 'gadgetup' && evt.id === 1) console.log('clicked');
}
gui.closeWindow(win);
High-level GUI using gadtools.library. Handles layout, resizing, events, menus.
Windows
Create a window. gadgets is an array — see below. Returns a window handle (opaque object).
font may be {name, size}, e.g. {name:'topaz.font', size:8}, to force a fixed-width font (useful for columnar listviews).
Blocks until an event arrives. Returns {type, id?, code?, x?, y?, key?, width?, height?}.
Non-blocking variant.
Install a menu bar. Each entry: {title, items: [{label, id, key?}]}. Use '---' for a separator.
Enable/disable a gadget.
Read/write the value of a gadget (string, number, checkbox state, listview items, etc.).
Requesters
ASL file requester.
Gadget kinds
Pass these in gadgets: array when creating a window. Each has id, left, top, width, height (pixels or 'NN%' strings for layouts relative to the window; negative values anchor from the opposite edge).
| kind | Purpose | Events |
|---|---|---|
button | Push button with label | gadgetup |
string | Text entry, value initial | gadgetup on Enter |
text | Read-only text, value | — |
integer | Numeric entry, value | gadgetup |
checkbox | Boolean, value: 0/1 | gadgetup with code=0/1 |
cycle | Dropdown, items: [...], value index | gadgetup with code=index |
mx | Radio-button group, items, value index | gadgetdown with code=index |
slider | Horizontal slider, min, max, value | gadgetup/mousemove |
scroller | Vertical scroller, max, value, visible | gadgetup with code=top |
listview | Scrollable list, items: [...], value selected index | gadgetup with code=index |
number | Read-only numeric display, value | — |
area | Clickable bevel box (custom drawing) | gadgetdown/gadgetup/mousemove with evt.x, evt.y |
Set flex: true on a gadget to make it expand vertically to fill available space (for a listview that grows with the window).
Drawing (gui.gfx)
For custom drawing on a gui window's RastPort:
gui.gfx.setColor, setBColor, setDrawMode (0=JAM1, 1=JAM2, 2=COMPLEMENT/XOR, 4=INVERSVID), moveTo, lineTo, drawLine, drawRect, fillRect, drawCircle, fillCircle, drawEllipse, drawText, setPixel, getPixel, clear, waitTOF (vsync), innerSize, setFont.
intuition — low-level windows
var ui = require('intuition');
var win = ui.openWindow({ title: 'Raw', width: 320, height: 200 });
while (true) {
var evt = win.waitEvent();
if (evt.type === 'close') break;
}
win.close();
Low-level wrapper over intuition.library for plain Intuition windows — no GadTools widgets, just a blank surface you can draw on. Use this when gui is too heavy or when you want total control (games, demos, custom toolkits).
width/height are the inner (drawable) dimensions. Returns a window handle with methods close(), waitEvent(), pollEvent(), plus properties width, height, innerWidth, innerHeight.
Events: close, mousedown, mouseup, mousemove, keypress (with code and key), resize (when window is resized), refresh.
Size of the active public screen (usually Workbench).
Simple modal requesters via EasyRequestArgs.
Graphics (ui.gfx)
Same API surface as gui.gfx. Examples: ui.gfx.setColor(win, 1), ui.gfx.drawLine(win, 10,10, 100,50), etc.
clipboard
var clip = require('clipboard');
clip.write('hello');
var text = clip.read();
clip.clear();
Read/write the standard AmigaOS clipboard unit 0. Uses iffparse.library to read/write FTXT/CHRS chunks — compatible with all standard Amiga text editors.
Returns "" if the clipboard is empty or contains no text. Reads up to 1 MB per chunk.
Returns true on success.
Empties the clipboard (writes an empty FTXT).
arexx
var arexx = require('arexx');
var r = arexx.send('EDITOR', 'REDRAW');
console.log(r.rc, r.result);
Communicate with ARexx-aware AmigaOS applications via message ports.
Send a command to a port and wait for the reply. rc is the ARexx return code (0 on success, non-zero on error). result is the string result, or an error description if the port wasn't found.
Create a named port that other applications can send commands to.
Non-blocking; returns null if no message is waiting.
Blocks until a message arrives.
Reply to a received message.
Returns the names of all public ports in the system.
amiga — FFI (call any library)
var amiga = require('amiga');
var intBase = amiga.openLibrary('intuition.library', 37);
var version = amiga.peek16(intBase, 20); // lib_Version
amiga.closeLibrary(intBase);
Escape hatch for calling AmigaOS libraries directly from JavaScript. Useful when a feature you need isn't wrapped in a higher-level NodeAmiga module.
Libraries
Returns the library base pointer as a number, or 0 on failure.
Memory
Default flags: MEMF_PUBLIC|MEMF_CLEAR. Allocations are tracked and freed automatically on exit if you forget.
Read an unsigned byte/word/long.
Read a null-terminated string (default max 4096 bytes).
No bounds check! You are responsible for making sure str fits. Allocate enough with allocMem first.
Allocate an AmigaOS-owned buffer and copy the string in. Tracked for auto-cleanup.
Allocate a TagItem array. Terminate your list with TAG_DONE (value 0) or the last pair; makeTags handles the terminator automatically.
Function calls
Call a library function at the given LVO offset (negative, e.g. -216 for exec AvailMem). regs is an object like {d0: ..., d1: ..., a0: ...}. Returns the value in d0 as a number.
Uses an assembly trampoline (ffi_asm.s) to load d0-d7 and a0-a5 from your object, sets a6 to base automatically, then calls the function.
// example: exec AvailMem(MEMF_CHIP) via FFI
var execLib = amiga.execBase();
var chip = amiga.call(execLib, -216, { d1: 0x02 }); // MEMF_CHIP
console.log('Chip free:', chip, 'bytes');
FFI is unsafe — by design
This module bypasses all type checking. Incorrect register values or out-of-bounds writes will crash your Amiga. Use it carefully and test on real hardware (or an emulator snapshot) before shipping.