@gct256/hexdump
v0.1.2
Published
A finely customizable hex dump utility.
Downloads
24
Readme
hexdump
- A finely customizable hex dump utility.
Install
$ npm install @gct256/hexdump
# or
$ yarn add @gct256/hexdump
Usage
code:
import { hexdump } from '@gct256/hexdump';
const buffer = Buffer.alloc(32);
console.debug(hexdump(buffer).join('\n'));
output:
00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
Interface
hexdump(buffer: BufferLike, {
countPerLine: number = 16;
start?: number;
end?: number;
endianness: 'big' | 'little' = 'little',
formatters?: { [FormatterSection]: Formatter },
appenders?: { [AppenderSection]: Appender },
disableDefaultAppenders: boolean = false,
decorators?: { [DecoratorSection]: Decorator[] }[] | { [DecoratorSection]: Decorator[] },
borders?: { [BorderSection]: Border[] },
}) => string[]
- buffer
- target for dump.
- allow types:
number[]
string
(convert to Buffer with utf8 encoding)ArrayBuffer
Uint8Array
,ClampledUint8Array
,Int8Array
Uint16Array
,Int16Array
(use endianness option)Uint32Array
,Int32Array
(use endianness option)Buffer
- countPerLine
- output value count per line.
- start
- If set, start dumping from this address.
- If not set, start dumping from first. (default)
- end
- If set, end dump at this address.
- If not set, dump to end of target. (default)
- endianness
- Use big/little endian byte order with int16/int32 array.
- formatters
- Value formatters.
- appenders
- Append value output handlers.
- If not set, use default appenders. (when disableDefaultAppenders is not true)
- disableDefaultAppenders
- Disable default appenders.
- decorators
- Output decorators.
- borders
- Border renderers.
Customize
TODO...