BREAKING CHANGE(core): update
This commit is contained in:
parent
f233cb1dcd
commit
f11114f6dc
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartbuffer',
|
name: '@push.rocks/smartbuffer',
|
||||||
version: '2.0.3',
|
version: '3.0.0',
|
||||||
description: 'A library for managing ArrayBufferLike structures including conversion between Base64 and Uint8Array, and buffer validation.'
|
description: 'A library for managing ArrayBufferLike structures including conversion between Base64 and Uint8Array, and buffer validation.'
|
||||||
}
|
}
|
||||||
|
14
ts/index.ts
14
ts/index.ts
@ -10,16 +10,6 @@ export function base64ToUint8Array(base64: string): Uint8Array {
|
|||||||
return plugins.uInt8ArrayExtras.base64ToUint8Array(base64);
|
return plugins.uInt8ArrayExtras.base64ToUint8Array(base64);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isBufferLike(obj: any): obj is ArrayBufferLike | Buffer {
|
export const isUint8Array = (obj: any): obj is Uint8Array => {
|
||||||
// Check for ArrayBufferLike objects in any environment
|
return plugins.uInt8ArrayExtras.isUint8Array(obj);
|
||||||
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;
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user