import { ConverterSet, ConverterType } from '../domain.js'; export const bytes: ConverterSet = { types: ['google.protobuf.BytesValue', 'BYTES'], [ConverterType.TO_JSON]: { transform: (val: number[]) => { const chars = val.reduce((res, c) => res + String.fromCharCode(c), ''); return btoa(chars); }, }, [ConverterType.FROM_JSON]: { transform: (val: string) => { return Uint8Array.from(atob(val), (c) => c.charCodeAt(0)); }, }, };