File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 1- import { TextEncoder } from '@exodus/bytes/encoding.js'
1+ import { TextEncoder , isomorphicEncode } from '@exodus/bytes/encoding.js'
22import { test } from 'node:test'
33
4- test ( 'TextEncoder returns non-pooled buffers ' , ( t ) => {
4+ test ( 'TextEncoder returns non-pooled Uint8Array instances ' , ( t ) => {
55 const encoder = new TextEncoder ( )
66 for ( let i = 0 ; i < 256 ; i ++ ) {
77 t . assert . strictEqual ( encoder . encode ( 'x' . repeat ( 128 ) ) . buffer . byteLength , 128 )
@@ -19,3 +19,21 @@ test('TextEncoder returns non-pooled buffers', (t) => {
1919 t . assert . strictEqual ( encoder . encode ( '' ) . buffer . byteLength , 0 )
2020 }
2121} )
22+
23+ test ( 'isomorphicEncode returns non-pooled Uint8Array instances' , ( t ) => {
24+ for ( let i = 0 ; i < 256 ; i ++ ) {
25+ t . assert . strictEqual ( isomorphicEncode ( 'x' . repeat ( 128 ) ) . buffer . byteLength , 128 )
26+ }
27+
28+ for ( let i = 0 ; i < 256 ; i ++ ) {
29+ t . assert . strictEqual ( isomorphicEncode ( 'x' . repeat ( 64 ) ) . buffer . byteLength , 64 )
30+ }
31+
32+ for ( let i = 0 ; i < 512 ; i ++ ) {
33+ t . assert . strictEqual ( isomorphicEncode ( 'x' . repeat ( 32 ) ) . buffer . byteLength , 32 )
34+ }
35+
36+ for ( let i = 0 ; i < 512 ; i ++ ) {
37+ t . assert . strictEqual ( isomorphicEncode ( '' ) . buffer . byteLength , 0 )
38+ }
39+ } )
You can’t perform that action at this time.
0 commit comments