File tree Expand file tree Collapse file tree 7 files changed +41
-3
lines changed Expand file tree Collapse file tree 7 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 14
14
"browser" : {
15
15
"fs-extra" : false ,
16
16
"./src/text-encoder.js" : " ./src/text-encoder.browser.js" ,
17
+ "./src/text-decoder.js" : " ./src/text-decoder.browser.js" ,
17
18
"./src/temp-dir.js" : " ./src/temp-dir.browser.js" ,
18
19
"./src/path-join.js" : " ./src/path-join.browser.js"
19
20
},
Original file line number Diff line number Diff line change 4
4
const fetch = require ( 'node-fetch' )
5
5
const merge = require ( 'merge-options' ) . bind ( { ignoreUndefined : true } )
6
6
const { URL , URLSearchParams } = require ( 'iso-url' )
7
- const TextDecoder = require ( './text-encoder ' )
7
+ const TextDecoder = require ( './text-decoder ' )
8
8
const AbortController = require ( 'abort-controller' )
9
9
const anySignal = require ( 'any-signal' )
10
10
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ module . exports = require ( './globalthis' ) . TextDecoder
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+ module . exports = require ( 'util' ) . TextDecoder
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- module . exports = require ( './globalthis' ) . TextDecoder
3
+ module . exports = require ( './globalthis' ) . TextEncoder
Original file line number Diff line number Diff line change 1
1
'use strict'
2
- module . exports = require ( 'util' ) . TextDecoder
2
+ module . exports = require ( 'util' ) . TextEncoder
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ /* eslint-env mocha */
4
+ const { expect } = require ( 'aegir/utils/chai' )
5
+ const TextEncoder = require ( '../src/text-encoder' )
6
+ const TextDecoder = require ( '../src/text-decoder' )
7
+
8
+ describe ( 'text encode/decode' , ( ) => {
9
+ const data = Uint8Array . from ( [
10
+ 104 ,
11
+ 101 ,
12
+ 108 ,
13
+ 108 ,
14
+ 111 ,
15
+ 32 ,
16
+ 119 ,
17
+ 111 ,
18
+ 114 ,
19
+ 108 ,
20
+ 100
21
+ ] )
22
+
23
+ it ( 'can encode text' , ( ) => {
24
+ const bytes = new TextEncoder ( ) . encode ( 'hello world' )
25
+ expect ( bytes ) . to . be . deep . equal ( data )
26
+ } )
27
+
28
+ it ( 'can decode text' , ( ) => {
29
+ const text = new TextDecoder ( ) . decode ( data )
30
+ expect ( text ) . to . be . equal ( 'hello world' )
31
+ } )
32
+ } )
You can’t perform that action at this time.
0 commit comments