25 lines
772 B
TypeScript
25 lines
772 B
TypeScript
import * as plugins from './smartbuffer.plugins.js';
|
|
|
|
export const uInt8ArrayExtras = plugins.uInt8ArrayExtras;
|
|
|
|
export function uInt8ArrayToBase64(uInt8Array: Uint8Array): string {
|
|
return plugins.uInt8ArrayExtras.uint8ArrayToBase64(uInt8Array);
|
|
}
|
|
|
|
export function base64ToUint8Array(base64: string): Uint8Array {
|
|
return plugins.uInt8ArrayExtras.base64ToUint8Array(base64);
|
|
}
|
|
|
|
export function isBufferLike(obj: any): obj is ArrayBufferLike | Buffer {
|
|
// Check for ArrayBufferLike objects in any environment
|
|
if (obj && typeof obj.byteLength === 'number') {
|
|
return true;
|
|
}
|
|
|
|
// Additional check specific to Node.js environment for Buffer objects
|
|
if (typeof Buffer !== 'undefined' && Buffer.isBuffer) {
|
|
return Buffer.isBuffer(obj);
|
|
}
|
|
|
|
return false;
|
|
} |