fix(core): update
This commit is contained in:
parent
d42bf699f7
commit
4f5282e5cd
15
test/test.ts
15
test/test.ts
@ -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';
|
import * as smartbuffer from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(smartbuffer);
|
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();
|
tap.start();
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartbuffer',
|
name: '@push.rocks/smartbuffer',
|
||||||
version: '1.0.5',
|
version: '1.0.6',
|
||||||
description: 'handle ArrayBufferLike structures'
|
description: 'handle ArrayBufferLike structures'
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,6 @@ export function base64ToArrayBuffer(base64: string): Uint8Array {
|
|||||||
return arrayBuffer;
|
return arrayBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isArrayBufferLike(obj: any): obj is ArrayBufferLike {
|
export function isBufferLike(obj: any): obj is ArrayBufferLike {
|
||||||
return obj && typeof obj.byteLength === 'number';
|
return obj && typeof obj.byteLength === 'number';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user