Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/core/byte-data.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const encodeUtf8 = require('encode-utf8')
const Mode = require('./mode')

function ByteData (data) {
this.mode = Mode.BYTE
if (typeof (data) === 'string') {
this.data = new TextEncoder().encode(data)
if (typeof (data) === 'string' && typeof TextEncoder !== 'undefined') {
Comment thread
Hao-yiwen marked this conversation as resolved.
Outdated
this.data = encodeUtf8(data);
this.data = new Uint8Array(data)
} else if (typeof (data) === 'string') {
this.data = new TextEncoder().encode(data);
} else {
this.data = new Uint8Array(data)
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
},
"dependencies": {
"dijkstrajs": "^1.0.1",
"encode-utf8": "^1.0.3",
"pngjs": "^5.0.0",
"yargs": "^15.3.1"
},
Expand Down