1- import { fromUint8Super , fromHex } from '@exodus/bytes/convert.js'
1+ import { fromTypedArray , fromHex } from '@exodus/bytes/convert.js'
22import { describe , test } from 'node:test'
33
44const raw = [ new Uint8Array ( ) , new Uint8Array ( [ 0 ] ) , new Uint8Array ( [ 1 ] ) , new Uint8Array ( [ 255 ] ) ]
@@ -12,22 +12,22 @@ const pool = raw.map((uint8) => {
1212 return { uint8, buffer, hex : buffer . toString ( 'hex' ) }
1313} )
1414
15- describe ( 'fromUint8Super ' , ( ) => {
15+ describe ( 'fromTypedArray ' , ( ) => {
1616 test ( 'invalid input' , ( t ) => {
17- for ( const input of [ null , undefined , [ ] , [ 1 , 2 ] , new Uint16Array ( 1 ) , 'string' ] ) {
18- t . assert . throws ( ( ) => fromUint8Super ( input ) )
17+ for ( const input of [ null , undefined , [ ] , [ 1 , 2 ] , 'string' ] ) {
18+ t . assert . throws ( ( ) => fromTypedArray ( input ) )
1919 for ( const form of [ 'uint8' , 'buffer' , 'hex' ] ) {
20- t . assert . throws ( ( ) => fromUint8Super ( input , form ) )
20+ t . assert . throws ( ( ) => fromTypedArray ( input , form ) )
2121 }
2222 }
2323 } )
2424
2525 test ( 'uint8' , ( t ) => {
2626 for ( const { buffer, uint8 } of pool ) {
27- t . assert . strictEqual ( fromUint8Super ( uint8 ) , uint8 )
28- t . assert . strictEqual ( fromUint8Super ( uint8 , 'uint8' ) , uint8 )
29- const a = fromUint8Super ( buffer )
30- const b = fromUint8Super ( buffer , 'uint8' )
27+ t . assert . strictEqual ( fromTypedArray ( uint8 ) , uint8 )
28+ t . assert . strictEqual ( fromTypedArray ( uint8 , 'uint8' ) , uint8 )
29+ const a = fromTypedArray ( buffer )
30+ const b = fromTypedArray ( buffer , 'uint8' )
3131 t . assert . deepStrictEqual ( a , uint8 )
3232 t . assert . strictEqual ( a . buffer , buffer . buffer )
3333 t . assert . deepStrictEqual ( b , uint8 )
@@ -37,17 +37,17 @@ describe('fromUint8Super', () => {
3737
3838 test ( 'buffer' , ( t ) => {
3939 for ( const { uint8, buffer } of pool ) {
40- t . assert . strictEqual ( fromUint8Super ( buffer , 'buffer' ) , buffer )
41- const a = fromUint8Super ( uint8 , 'buffer' )
40+ t . assert . strictEqual ( fromTypedArray ( buffer , 'buffer' ) , buffer )
41+ const a = fromTypedArray ( uint8 , 'buffer' )
4242 t . assert . deepStrictEqual ( a , buffer )
4343 t . assert . strictEqual ( a . buffer , uint8 . buffer )
4444 }
4545 } )
4646
4747 test ( 'hex' , ( t ) => {
4848 for ( const { uint8, buffer, hex} of pool ) {
49- t . assert . strictEqual ( fromUint8Super ( uint8 , 'hex' ) , hex )
50- t . assert . strictEqual ( fromUint8Super ( buffer , 'hex' ) , hex )
49+ t . assert . strictEqual ( fromTypedArray ( uint8 , 'hex' ) , hex )
50+ t . assert . strictEqual ( fromTypedArray ( buffer , 'hex' ) , hex )
5151 }
5252 } )
5353} )
0 commit comments