fix(core): update

This commit is contained in:
Philipp Kunz 2024-02-25 01:45:48 +01:00
parent d42bf699f7
commit 4f5282e5cd
3 changed files with 16 additions and 3 deletions

View File

@ -1,8 +1,21 @@
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as smartbuffer from '../ts/index.js';
tap.test('first test', async () => {
console.log(smartbuffer);
});
tap.test('should recognize different buffer like objects', async () => {
const testBuffer = Buffer.from('test');
const testArrayBuffer = new ArrayBuffer(4);
const testUint8Array = new Uint8Array(testArrayBuffer);
testUint8Array[0] = 116;
testUint8Array[1] = 101;
testUint8Array[2] = 115;
testUint8Array[3] = 116;
expect(smartbuffer.isBufferLike(testBuffer)).toBeTrue();
expect(smartbuffer.isBufferLike(testArrayBuffer)).toBeTrue();
expect(smartbuffer.isBufferLike(testUint8Array)).toBeTrue();
});
tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartbuffer',
version: '1.0.5',
version: '1.0.6',
description: 'handle ArrayBufferLike structures'
}

View File

@ -62,6 +62,6 @@ export function base64ToArrayBuffer(base64: string): Uint8Array {
return arrayBuffer;
}
export function isArrayBufferLike(obj: any): obj is ArrayBufferLike {
export function isBufferLike(obj: any): obj is ArrayBufferLike {
return obj && typeof obj.byteLength === 'number';
}