( read: (bytes: Uint8Array, offset: number, size: number) => A, encode: (value: A) => Uint8Array, write?: (sink: ValueSink, value: A) => void )
| 1047 | |
| 1048 | /** A codec whose `decode` is its `read` over the whole of its bytes. */ |
| 1049 | const codecOf = <A>( |
| 1050 | read: (bytes: Uint8Array, offset: number, size: number) => A, |
| 1051 | encode: (value: A) => Uint8Array, |
| 1052 | write?: (sink: ValueSink, value: A) => void |
| 1053 | ): UnsafeCodec<A> => { |
| 1054 | const decode = (bytes: Uint8Array): A => read(bytes, 0, bytes.length) |
| 1055 | return write === undefined ? { encode, decode, read } : { encode, decode, read, write } |
| 1056 | } |
| 1057 | |
| 1058 | /** A fresh copy of the first four staged bytes; `set` costs more than the stores. */ |
| 1059 | const takeScratch4 = (): Uint8Array => { |
no outgoing calls
no test coverage detected