Binary data in Relish wire format
Relish schema defining the expected structure
Result containing decoded value, or DecodeError on failure
import { fromRelish, RArray, RU32 } from '@grounds/schema';
const schema = RArray(RU32());
const bytes = new Uint8Array([...]); // from network or storage
fromRelish<Array<number>>(bytes, schema).match(
(value) => {
// value: Array<number> ready to use
console.log('Decoded array:', value);
},
(error) => {
if (error.code === 'UNEXPECTED_EOF') {
console.error('Incomplete data');
}
}
);
This function provides true API symmetry with toRelish per ADR 0001:
The symmetry simplifies reasoning about the API and enables clean composition
with streaming operations in @grounds/stream.
Internally decodes to raw JavaScript values (not wrapped RelishValue), then validates against the schema to ensure type safety.
Converts Relish binary bytes to a JavaScript value using a schema.
Decodes bytes from Relish wire format and converts to the schema's JavaScript type in a single operation.