fix(core): update

This commit is contained in:
Philipp Kunz 2024-04-17 20:33:24 +02:00
parent 158614c62c
commit 63e3b492e6
2 changed files with 15 additions and 1 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartbuffer',
version: '3.0.0',
version: '3.0.1',
description: 'A library for managing ArrayBufferLike structures including conversion between Base64 and Uint8Array, and buffer validation.'
}

View File

@ -12,4 +12,18 @@ export function base64ToUint8Array(base64: string): Uint8Array {
export const isUint8Array = (obj: any): obj is Uint8Array => {
return plugins.uInt8ArrayExtras.isUint8Array(obj);
}
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;
}