MCPcopy Create free account
hub / github.com/Effect-TS/effect / codecOf

Function codecOf

packages/sql/pg/src/PgTypes.ts:1049–1056  ·  view source on GitHub ↗
(
  read: (bytes: Uint8Array, offset: number, size: number) => A,
  encode: (value: A) => Uint8Array,
  write?: (sink: ValueSink, value: A) => void
)

Source from the content-addressed store, hash-verified

1047
1048/** A codec whose `decode` is its `read` over the whole of its bytes. */
1049const 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. */
1059const takeScratch4 = (): Uint8Array => {

Callers 5

PgTypes.tsFile · 0.70
makeArrayCodecFunction · 0.70
makeRangeCodecFunction · 0.70
makeMultirangeCodecFunction · 0.70
makeRecordCodecFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected