Skip to content

Commit f7a932d

Browse files
microbit-rosslowemicrobit-carlos
authored andcommitted
common: Use text-encoder-lite for encoding (#6)
1 parent 6e89490 commit f7a932d

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

package-lock.json

Lines changed: 3 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,14 @@
4646
},
4747
"dependencies": {
4848
"nrf-intel-hex": "1.3.0",
49-
"text-encoding": "0.7.0"
49+
"text-encoder-lite": "solderjs/TextEncoderLite#e1e031b4a7fb89c35629340a61a06ec4f50ce7cb"
5050
},
5151
"devDependencies": {
5252
"@babel/core": "7.2.2",
5353
"@babel/preset-env": "7.3.1",
5454
"@types/jest": "23.3.10",
5555
"@types/node": "8.10.*",
5656
"@types/prettier": "1.15.2",
57-
"@types/text-encoding": "0.0.35",
5857
"jest": "23.6.0",
5958
"prettier": "1.15.3",
6059
"rollup": "0.68.2",

src/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* General utilities.
33
*/
44

5-
import encoding from 'text-encoding';
5+
import { TextDecoderLite, TextEncoderLite } from 'text-encoder-lite';
66

77
/**
88
* Marker placed inside the MicroPython hex string to indicate where to
@@ -26,7 +26,7 @@ export function cleanseOldHexFormat(intelHex: string): string {
2626
* @returns A byte array with the encoded data.
2727
*/
2828
export function strToBytes(str: string): Uint8Array {
29-
const encoder = new encoding.TextEncoder();
29+
const encoder = new TextEncoderLite();
3030
return encoder.encode(str);
3131
}
3232

@@ -36,7 +36,7 @@ export function strToBytes(str: string): Uint8Array {
3636
* @returns String output from the conversion.
3737
*/
3838
export function bytesToStr(byteArray: Uint8Array): string {
39-
const decoder = new encoding.TextDecoder();
39+
const decoder = new TextDecoderLite();
4040
return decoder.decode(byteArray);
4141
}
4242

src/types/text-encoder-lite.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module 'text-encoder-lite';

0 commit comments

Comments
 (0)