Add session, client and server with the promise result API

This commit is contained in:
2026-08-25 16:46:32 +02:00
parent 1827ab5964
commit fd2f98464f
11 changed files with 1819 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
import { cmds, cmdsById } from './commands.ts';
import { consts, constsById } from './constants.ts';
import { encodings } from './encodings.ts';
import { errors, errorsById } from './errors.ts';
import { tlvs, tlvsById } from './tlvs.ts';
import { types } from './types.ts';
export const defs = {
cmds,
cmdsById,
consts,
constsById,
encodings,
errors,
errorsById,
tlvs,
tlvsById,
types,
};
+9
View File
@@ -24,6 +24,15 @@ export type WireType<T extends ParamValue = ParamValue> = {
write: (value: ParamValue, buffer: Buffer, offset: number) => VoidResult;
};
/** Renders a parameter as text without ever falling back to "[object Object]". */
export function paramText(value: ParamValue | undefined): string {
if (typeof value === 'string') return value;
if (typeof value === 'number') return value.toString();
if (Buffer.isBuffer(value)) return value.toString('ascii');
return '';
}
function outOfRange(buffer: Buffer, offset: number, needed: number): Error | undefined {
if (offset < 0 || needed < 0 || offset + needed > buffer.length) {
return new Error(