1- import { fromTypedArray , fromHex } from '@exodus/bytes/convert .js'
1+ import { fromTypedArray } from '@exodus/bytes/array .js'
22import { describe , test } from 'node:test'
33
44const raw = [ new Uint8Array ( ) , new Uint8Array ( [ 0 ] ) , new Uint8Array ( [ 1 ] ) , new Uint8Array ( [ 255 ] ) ]
@@ -16,7 +16,7 @@ describe('fromTypedArray', () => {
1616 test ( 'invalid input' , ( t ) => {
1717 for ( const input of [ null , undefined , [ ] , [ 1 , 2 ] , 'string' ] ) {
1818 t . assert . throws ( ( ) => fromTypedArray ( input ) )
19- for ( const form of [ 'uint8' , 'buffer' , 'hex' ] ) {
19+ for ( const form of [ 'uint8' , 'buffer' ] ) {
2020 t . assert . throws ( ( ) => fromTypedArray ( input , form ) )
2121 }
2222 }
@@ -43,40 +43,4 @@ describe('fromTypedArray', () => {
4343 t . assert . strictEqual ( a . buffer , uint8 . buffer )
4444 }
4545 } )
46-
47- test ( 'hex' , ( t ) => {
48- for ( const { uint8, buffer, hex} of pool ) {
49- t . assert . strictEqual ( fromTypedArray ( uint8 , 'hex' ) , hex )
50- t . assert . strictEqual ( fromTypedArray ( buffer , 'hex' ) , hex )
51- }
52- } )
53- } )
54-
55- describe ( 'fromHex' , ( ) => {
56- test ( 'invalid input' , ( t ) => {
57- for ( const input of [ null , undefined , [ ] , [ 1 , 2 ] , [ '00' ] , new Uint8Array ( ) , 'a' , '0x00' , 'ag' ] ) {
58- if ( Uint8Array . fromHex ) t . assert . throws ( ( ) => Uint8Array . fromHex ( input ) )
59- t . assert . throws ( ( ) => fromHex ( input ) )
60- for ( const form of [ 'uint8' , 'buffer' , 'hex' ] ) {
61- t . assert . throws ( ( ) => fromHex ( input , form ) )
62- }
63- }
64- } )
65-
66- test ( 'uint8' , ( t ) => {
67- for ( const { hex, uint8 } of pool ) {
68- t . assert . deepStrictEqual ( fromHex ( hex ) , uint8 )
69- t . assert . deepStrictEqual ( fromHex ( hex , 'uint8' ) , uint8 )
70- }
71- } )
72-
73- test ( 'buffer' , ( t ) => {
74- for ( const { hex, buffer } of pool ) {
75- t . assert . deepStrictEqual ( fromHex ( hex , 'buffer' ) , buffer )
76- }
77- } )
78-
79- test ( 'hex' , ( t ) => {
80- for ( const { hex } of pool ) t . assert . strictEqual ( fromHex ( hex , 'hex' ) , hex )
81- } )
8246} )
0 commit comments