UNPKG

ts-mls

Version:

[![CI](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml/badge.svg)](https://github.com/LukaJCB/ts-mls/actions/workflows/ci.yml) [![npm version](https://badge.fury.io/js/ts-mls.svg)](https://badge.fury.io/js/ts-mls) [![Coverage Status](https://co

29 lines 927 B
export function contramapEncoders(encoders, toTuple) { return (value) => { const values = toTuple(value); const encodedParts = new Array(values.length); let totalLength = 0; for (let i = 0; i < values.length; i++) { const encoded = encoders[i](values[i]); totalLength += encoded.byteLength; encodedParts[i] = encoded; } const result = new Uint8Array(totalLength); let offset = 0; for (const arr of encodedParts) { result.set(arr, offset); offset += arr.length; } return result; }; } export function composeEncoders(encoders) { return (values) => contramapEncoders(encoders, (t) => t)(values); } export function contramapEncoder(enc, f) { return (u) => enc(f(u)); } export function encodeVoid() { return () => new Uint8Array(); } //# sourceMappingURL=tlsEncoder.js.map