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.

ExportSemantics
BufferFull 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, FileWHATWG Blob/File constructors (shared with the global surface).
atob, btoaBase64 helpers (same as globals).
isAscii, isUtf8Validation predicates.
constantsMAX_LENGTH / MAX_STRING_LENGTH constants object.
kMaxLength, kStringMaxLength, INSPECT_MAX_BYTESNumeric constants.
resolveObjectURLPresent as a function.
transcodeFunctional. 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.

ExportSemantics
format, formatWithOptionsPrintf-style formatting; %s %d %o %j handled.
inspectReal object inspector (nested objects, arrays, Maps render in Node shape; depth option honored).
promisify, callbackifyCallback/promise conversion.
inherits, _extend, deprecate, debuglog, debugLegacy helpers, functional.
typesThe full util/types namespace (see below).
isDeepStrictEqualFunctional.
parseArgsWorking for the common options/values shape.
parseEnv, diff, getCallSites, getSystemErrorName/Map/Message, stripVTControlCharacters, toUSVString, abortedPresent as functions.
styleTextPresent, but returns the text unstyled (no ANSI escapes) in the probed non-TTY environment; treat as pass-through.
TextEncoder, TextDecoderSame constructors as the globals.
MIMEType, MIMEParamsPresent.
transferableAbortController, transferableAbortSignalPresent.
isArrayDeprecated Node alias, present.
_errnoException, _exceptionWithHostPort, convertProcessSignalToExitCode, setTraceSigIntInternal-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.

ExportSemantics
parse / decodeRepeated keys collect into arrays.
stringify / encodeArrays fan out to repeated keys; percent-encodes values.
escape, unescape, unescapeBufferPercent-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.

ExportSemantics
gzipSync/gunzipSync, deflateSync/inflateSync, deflateRawSync/inflateRawSync, unzipSyncRound-trips.
gzip/gunzip, deflate/inflate, deflateRaw/inflateRaw, unzipCallback forms (zlib.gzip(data, cb)).
brotliCompress(Sync) / brotliDecompress(Sync)Round-trip.
crc32crc32("abc")891568578.
createGzip, createGunzip, createDeflate(Raw), createInflate(Raw), createUnzip, createBrotliCompress, createBrotliDecompressReturn stream-shaped objects with write/on; usable in pipelines.
Gzip, Gunzip, Deflate, DeflateRaw, Inflate, InflateRaw, Unzip, BrotliCompress, BrotliDecompressClass constructors present.
constants, codesConstants objects present.
zstdCompress(Sync), zstdDecompress(Sync), createZstdCompress, createZstdDecompress, ZstdCompress, ZstdDecompressNot 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.

ExportSemantics
createHash / Hash, hashsha256("abc") correct. getHashes() includes sha1, sha256, sha384, sha512, md5, and more.
createHmac / HmacPresent and functional.
randomBytes, randomFill(Sync), randomInt, randomUUID, randomUUIDv7, getRandomValuesWorking.
pbkdf2(Sync), scrypt(Sync), hkdf(Sync)Working key derivation (PBKDF2, scrypt, HKDF).
argon2, argon2SyncPresent (Bun-style extension surface).
createCipheriv / createDecipheriv (Cipheriv/Decipheriv)AES-256-CBC round-trip; getCiphers/getCipherInfo present.
generateKeyPair(Sync), generateKey(Sync), createPublicKey, createPrivateKey, createSecretKey, KeyObjectgenerateKeyPairSync("ed25519") plus sign/verify round-trips.
sign/verify, createSign/createVerifyOne-shot form works with ed25519.
publicEncrypt/privateDecrypt, privateEncrypt/publicDecryptPresent.
createDiffieHellman(Group), getDiffieHellman, diffieHellman, createECDH, ECDHPresent.
checkPrime(Sync), generatePrime(Sync)Present.
encapsulate, decapsulatePresent (KEM surface).
timingSafeEqualPresent and functional.
X509Certificate, CertificatePresent (backed by Cruft's own X.509 support).
getCurves, constantsPresent.
webcrypto, subtleThe WebCrypto surface, including deriveBits/deriveKey key derivation (see the WebCrypto reference).
getFips, setFips, setEngine, secureHeapUsedPresent; 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).

ExportSemantics
ok (and calling assert() directly)Functional.
equal/notEqual, strictEqual/notStrictEqualFunctional; failures throw AssertionError with code: "ERR_ASSERTION".
deepEqual/notDeepEqual, deepStrictEqual/notDeepStrictEqualFunctional for common shapes.
throws/doesNotThrow, rejects/doesNotRejectFunctional; throws matches constructor classes; rejects resolves correctly, but see gap below.
match/doesNotMatch, fail, ifErrorPresent.
AssertionError, AssertPresent.
strictThe strict-mode namespace (same object as node:assert/strict).
partialDeepStrictEqualFunctional. A partial match like partialDeepStrictEqual({a:1,b:2},{a:1}) passes.

Known compatibility exceptions:

  • AssertionError.operator is populated with the comparison operator (e.g. strictEqual), matching Node; actual/expected diff-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.