Skip to content

Commit b8bf3ca

Browse files
committed
react-native support with '@sinonjs/text-encoding' polyfill
1 parent 075f2fe commit b8bf3ca

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
This package provides [TextEncoder][] and [TextDecoder][] [Encoding Standard][]
88
APIs in a universal package. In the browsers it just exposes existing globals,
99
in nodejs it exposes globals in newer node versions and ones from `util` module
10-
in older versions.
10+
in older versions, and in the React Native environments it exposes these from
11+
the [@sinonjs/text-encoding](https://www.npmjs.com/package/text-encoding)
12+
polyfill (installed as an optional dependency).
1113

1214
Package also works as ES module and CommonJS module.
1315

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
],
99
"type": "module",
1010
"browser": "./src/lib.browser.js",
11+
"react-native": "./src/lib.react-native.js",
1112
"main": "./src/lib.cjs",
1213
"module": "./src/lib.js",
1314
"types": "./src/lib.d.ts",
@@ -35,5 +36,8 @@
3536
"devDependencies": {
3637
"mocha": "8.2.1",
3738
"playwright-test": "1.2.0"
39+
},
40+
"optionalDependencies": {
41+
"@sinonjs/text-encoding": "0.7.1"
3842
}
3943
}

src/lib.react-native.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict"
2+
3+
const textEncoding = require("@sinonjs/text-encoding")
4+
exports.TextEncoder = textEncoding.TextEncoder
5+
exports.TextDecoder = textEncoding.TextDecoder

0 commit comments

Comments
 (0)