TextEncoder polyfill

This commit is contained in:
Jaco Greeff
2019-03-20 12:29:59 +01:00
parent ca11650d58
commit f7747520c6
2 changed files with 5 additions and 2 deletions
+5
View File
@@ -13,6 +13,11 @@ SRC=build/wasm.js
sed -i -e 's/var wasm;/const crypto = require('\''crypto'\''); let wasm; const requires = { crypto };/g' $SRC
sed -i -e 's/return addHeapObject(require(varg0));/return addHeapObject(requires[varg0]);/g' $SRC
# this creates issues in both the browser and RN (@polkadot/util has a polyfill)
sed -i -e 's/const TextEncoder = require('\''util'\'')\.TextEncoder;/const { stringToU8a } = require('\''@polkadot\/util'\'');/g' $SRC
sed -i -e 's/let cachedTextEncoder = new /\/\/ let cachedTextEncoder = new /g' $SRC
sed -i -e 's/cachedTextEncoder\.encode/stringToU8a/g' $SRC
echo "*** Testing package"
cargo test -- --nocapture
node ./test/wasm.js
-2
View File
@@ -15,8 +15,6 @@ sed -i -e 's/return addHeapObject(require(varg0));/return addHeapObject(requires
# this creates issues in both the browser and RN (@polkadot/util has a polyfill)
sed -i -e 's/const TextDecoder = require('\''util'\'')\.TextDecoder;/const { u8aToString } = require('\''@polkadot\/util'\'');/g' $SRC
# TextDecoder is not available on RN, so use the @polkadot/util replacement (with polyfill)
sed -i -e 's/let cachedTextDecoder = new /\/\/ let cachedTextDecoder = new /g' $SRC
sed -i -e 's/cachedTextDecoder\.decode/u8aToString/g' $SRC