index.uts 449 字节
Newer Older
DCloud-yyl's avatar
DCloud-yyl 已提交
1 2 3 4 5 6 7 8 9 10 11
import buffer from '@ohos.buffer';
import { ArrayBufferToBase64 } from '../interface.uts';
import { ArrayBufferToBase64Protocol, API_ARRAY_BUFFER_TO_BASE64 } from '../protocol.uts';

export const arrayBufferToBase64: ArrayBufferToBase64 = defineSyncApi<string>(
  API_ARRAY_BUFFER_TO_BASE64,
  (arrayBuffer: ArrayBuffer): string => {
    return buffer.from(arrayBuffer).toString('base64')
  },
  ArrayBufferToBase64Protocol
) as ArrayBufferToBase64