Data & utility modules
Reference for Cruft's Node data and utility modules, node:buffer, node:util, node:querystring, node:zlib, node:crypto, and node:assert, listing exactly which exports are installed and their gaps (for example, the zstd family throws and util.styleText returns text unstyled).
This page is the reference for Cruft's data-handling and utility Node modules: node:buffer, node:util (and node:util/types), node:querystring, node:zlib, node:crypto, and node:assert (and node:assert/strict). None of these has a dedicated guide page; the compatibility map classes them as focused-or-partial, so this page documents only what is actually installed in the host. Every export listed below is installed; anything not listed is not present. All modules resolve under both the node: prefix and the bare name (require("util") works), from both require and import.
node:buffer, focused
Buffer is a real binary type: a Uint8Array subclass with the Node read/write/encode surface. The module namespace is small compared to Node's, but the Buffer class itself carries the common ecosystem surface.
| Export | Semantics |
|---|---|
Buffer | Full common surface: from (string/array/ArrayBuffer/Buffer, with encodings including utf8, hex, base64, latin1), alloc, allocUnsafe, concat, byteLength, isBuffer, compare; instance toString(enc), slice/subarray, copy, fill, equals, indexOf, write, readUInt*/readInt*/readFloat*/readDouble* and write* (BE/LE), swap16/32/64, toJSON. |
Blob, File | WHATWG Blob/File constructors (shared with the global surface). |
atob, btoa | Base64 helpers (same as globals). |
isAscii, isUtf8 | Validation predicates. |
constants | MAX_LENGTH / MAX_STRING_LENGTH constants object. |
kMaxLength, kStringMaxLength, INSPECT_MAX_BYTES | Numeric constants. |
resolveObjectURL | Present as a function. |
transcode | Functional. Re-encodes between encodings, e.g. transcode(Buffer.from("hi"),"utf8","latin1") returns a buffer whose toString() is "hi". |
Example:
$ cruft -e 'console.log(Buffer.from("hi").toString("base64"), Buffer.from([0,0,1,0]).readUInt32BE(0))'
aGk= 256
Not implemented / gaps: SlowBuffer, Buffer.copyBytesFrom. Buffer is also a global; importing the module is optional.
node:util, focused
Eagerly installed (not lazy) because nearly every real package imports it. The formatter/inspector core is real and matches Node's common output shapes.
| Export | Semantics |
|---|---|
format, formatWithOptions | Printf-style formatting; %s %d %o %j handled. |
inspect | Real object inspector (nested objects, arrays, Maps render in Node shape; depth option honored). |
promisify, callbackify | Callback/promise conversion. |
inherits, _extend, deprecate, debuglog, debug | Legacy helpers, functional. |
types | The full util/types namespace (see below). |
isDeepStrictEqual | Functional. |
parseArgs | Working for the common options/values shape. |
parseEnv, diff, getCallSites, getSystemErrorName/Map/Message, stripVTControlCharacters, toUSVString, aborted | Present as functions. |
styleText | Present, but returns the text unstyled (no ANSI escapes) in the probed non-TTY environment; treat as pass-through. |
TextEncoder, TextDecoder | Same constructors as the globals. |
MIMEType, MIMEParams | Present. |
transferableAbortController, transferableAbortSignal | Present. |
isArray | Deprecated Node alias, present. |
_errnoException, _exceptionWithHostPort, convertProcessSignalToExitCode, setTraceSigInt | Internal-compat helpers, present. |
Example:
$ cruft -e 'const u=require("util"); console.log(u.format("%s=%d %o","n",42,{a:1}))'
n=42 { a: 1 }
Not implemented / gaps: getSystemErrorMessage-family fidelity is untested against real errnos; the deprecated is* predicate family (isBuffer, isDate, isRegExp, ...) is absent from the top-level namespace except isArray (use util.types). node:sys resolves to this module as in Node.
node:util/types, focused
All 43 Node util.types predicates are installed: isAnyArrayBuffer, isArrayBuffer, isSharedArrayBuffer, isArrayBufferView, isTypedArray, every per-typed-array predicate (isInt8Array ... isBigUint64Array, including isFloat16Array), isDataView, isDate, isRegExp, isMap/isSet and their iterator predicates, isWeakMap/isWeakSet, isPromise, isProxy, isNativeError, isGeneratorFunction/isGeneratorObject, isAsyncFunction, isModuleNamespaceObject, isArgumentsObject, boxed-primitive predicates (isNumberObject, isStringObject, isBooleanObject, isBigIntObject, isSymbolObject, isBoxedPrimitive), plus isExternal, isCryptoKey, isKeyObject.
node:querystring, focused
The classic (non-WHATWG) query codec. Small surface, fully present.
| Export | Semantics |
|---|---|
parse / decode | Repeated keys collect into arrays. |
stringify / encode | Arrays fan out to repeated keys; percent-encodes values. |
escape, unescape, unescapeBuffer | Percent-codec helpers. |
$ cruft -e 'const qs=require("querystring"); console.log(JSON.stringify(qs.parse("a=1&b=2&b=3")), qs.stringify({a:"x y",b:[1,2]}))'
{"a":"1","b":["2","3"]} a=x%20y&b=1&b=2
Custom sep/eq/decodeURIComponent/maxKeys options exist per the host compatibility-exception note. Not implemented / gaps: none at the namespace level.
node:zlib, partial
Gzip, deflate/deflate-raw, and brotli are real, in both sync and async (callback) forms, backed by Cruft's compression layer. Zstd throws not yet implemented.
| Export | Semantics |
|---|---|
gzipSync/gunzipSync, deflateSync/inflateSync, deflateRawSync/inflateRawSync, unzipSync | Round-trips. |
gzip/gunzip, deflate/inflate, deflateRaw/inflateRaw, unzip | Callback forms (zlib.gzip(data, cb)). |
brotliCompress(Sync) / brotliDecompress(Sync) | Round-trip. |
crc32 | crc32("abc") → 891568578. |
createGzip, createGunzip, createDeflate(Raw), createInflate(Raw), createUnzip, createBrotliCompress, createBrotliDecompress | Return stream-shaped objects with write/on; usable in pipelines. |
Gzip, Gunzip, Deflate, DeflateRaw, Inflate, InflateRaw, Unzip, BrotliCompress, BrotliDecompress | Class constructors present. |
constants, codes | Constants objects present. |
zstdCompress(Sync), zstdDecompress(Sync), createZstdCompress, createZstdDecompress, ZstdCompress, ZstdDecompress | Not yet implemented. zstdCompressSync("zz") throws TypeError: node:zlib.zstdCompressSync not yet implemented. Do not use. |
$ cruft -e 'const z=require("zlib"); console.log(z.gunzipSync(z.gzipSync("hello world")).toString())'
hello world
Not implemented / gaps: the entire zstd family throws not yet implemented (see above); dictionary options and flush-level fidelity are untested.
node:crypto, focused
The Node-flavored crypto module (distinct from the WebCrypto global, which is re-exported here as webcrypto/subtle). The primitive core is real: hashing, HMAC, key derivation, AES ciphers, sign/verify, key generation.
| Export | Semantics |
|---|---|
createHash / Hash, hash | sha256("abc") correct. getHashes() includes sha1, sha256, sha384, sha512, md5, and more. |
createHmac / Hmac | Present and functional. |
randomBytes, randomFill(Sync), randomInt, randomUUID, randomUUIDv7, getRandomValues | Working. |
pbkdf2(Sync), scrypt(Sync), hkdf(Sync) | Working key derivation (PBKDF2, scrypt, HKDF). |
argon2, argon2Sync | Present (Bun-style extension surface). |
createCipheriv / createDecipheriv (Cipheriv/Decipheriv) | AES-256-CBC round-trip; getCiphers/getCipherInfo present. |
generateKeyPair(Sync), generateKey(Sync), createPublicKey, createPrivateKey, createSecretKey, KeyObject | generateKeyPairSync("ed25519") plus sign/verify round-trips. |
sign/verify, createSign/createVerify | One-shot form works with ed25519. |
publicEncrypt/privateDecrypt, privateEncrypt/publicDecrypt | Present. |
createDiffieHellman(Group), getDiffieHellman, diffieHellman, createECDH, ECDH | Present. |
checkPrime(Sync), generatePrime(Sync) | Present. |
encapsulate, decapsulate | Present (KEM surface). |
timingSafeEqual | Present and functional. |
X509Certificate, Certificate | Present (backed by Cruft's own X.509 support). |
getCurves, constants | Present. |
webcrypto, subtle | The WebCrypto surface, including deriveBits/deriveKey key derivation (see the WebCrypto reference). |
getFips, setFips, setEngine, secureHeapUsed | Present; setEngine accepts any argument without effect (no OpenSSL engines exist here). Treat these as compatibility no-ops. |
$ cruft -e 'const c=require("crypto"); console.log(c.createHash("sha256").update("abc").digest("hex"))'
ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
Not implemented / gaps: no streaming Cipher/Decipher legacy (createCipher without iv), use the iv forms; per-algorithm coverage beyond the listed set (exotic curves, cipher modes) is not guaranteed; setEngine/FIPS toggles are inert.
node:assert / node:assert/strict, partial
assert resolves to a callable function (alias of ok) carrying the method surface; assert/strict is the same surface with the loose methods remapped to strict semantics (strict.equal(1, "1") throws ERR_ASSERTION).
| Export | Semantics |
|---|---|
ok (and calling assert() directly) | Functional. |
equal/notEqual, strictEqual/notStrictEqual | Functional; failures throw AssertionError with code: "ERR_ASSERTION". |
deepEqual/notDeepEqual, deepStrictEqual/notDeepStrictEqual | Functional for common shapes. |
throws/doesNotThrow, rejects/doesNotReject | Functional; throws matches constructor classes; rejects resolves correctly, but see gap below. |
match/doesNotMatch, fail, ifError | Present. |
AssertionError, Assert | Present. |
strict | The strict-mode namespace (same object as node:assert/strict). |
partialDeepStrictEqual | Functional. A partial match like partialDeepStrictEqual({a:1,b:2},{a:1}) passes. |
Known compatibility exceptions:
AssertionError.operatoris populated with the comparison operator (e.g.strictEqual), matching Node;actual/expecteddiff-rendering in messages is minimal (e.g. "deepStrictEqual failed").assert.rejects(promise)succeeds; passing a rejected promise directly resolves cleanly (exit code 0), no unhandled-rejection workaround needed.
Not implemented / gaps: CallTracker (absent, deprecated in Node), rich diff messages.