fix(core): update
This commit is contained in:
parent
bebc8b0ede
commit
87273cbbbd
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartbuffer',
|
name: '@push.rocks/smartbuffer',
|
||||||
version: '3.0.2',
|
version: '3.0.3',
|
||||||
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.'
|
||||||
}
|
}
|
||||||
|
13
ts/index.ts
13
ts/index.ts
@ -12,7 +12,7 @@ export function base64ToUint8Array(base64: string): Uint8Array {
|
|||||||
|
|
||||||
export const isUint8Array = (obj: any): obj is Uint8Array => {
|
export const isUint8Array = (obj: any): obj is Uint8Array => {
|
||||||
return plugins.uInt8ArrayExtras.isUint8Array(obj);
|
return plugins.uInt8ArrayExtras.isUint8Array(obj);
|
||||||
}
|
};
|
||||||
|
|
||||||
export function isBufferLike(obj: any): obj is ArrayBufferLike | Buffer {
|
export function isBufferLike(obj: any): obj is ArrayBufferLike | Buffer {
|
||||||
// Check for ArrayBufferLike objects in any environment
|
// Check for ArrayBufferLike objects in any environment
|
||||||
@ -26,4 +26,13 @@ export function isBufferLike(obj: any): obj is ArrayBufferLike | Buffer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertBufferToPureUint8Array(bufferArg: Buffer) {
|
||||||
|
// Create a new Uint8Array with the same length as the buffer
|
||||||
|
const uint8Array: Uint8Array = new Uint8Array(bufferArg.length);
|
||||||
|
|
||||||
|
// Copy the contents of the Buffer to the new Uint8Array
|
||||||
|
uint8Array.set(bufferArg);
|
||||||
|
return uint8Array;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user