UNPKG

json-type-cli

Version:

High-performance JSON Pointer implementation

21 lines (20 loc) 667 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CliCodecHex = void 0; class CliCodecHex { constructor() { this.id = 'hex'; this.description = 'Same as "raw", but encodes binary data as HEX octets'; } encode(value) { const buf = value instanceof Uint8Array ? value : new TextEncoder().encode(String(value)); const hex = Array.from(buf) .map((byte) => byte.toString(16).padStart(2, '0')) .join(' '); return new TextEncoder().encode(hex + '\n'); } decode(bytes) { throw new Error('Not available'); } } exports.CliCodecHex = CliCodecHex;