WIP: textencoder for RN

This commit is contained in:
Hadar 2019-09-11 00:21:21 +03:00
parent a2a7ef91bb
commit 0311969060

12
sea.js
View File

@ -170,17 +170,19 @@
}
api.subtle = (api.crypto||o).subtle || (api.crypto||o).webkitSubtle;
api.TextEncoder = window.TextEncoder;
api.TextDecoder = window.TextDecoder;
api.TextDecoder = window.TextDecoder;
api.random = (len) => Buffer.from(api.crypto.getRandomValues(new Uint8Array(Buffer.alloc(len))))
}
if(!api.TextDecoder)
{
const { TextEncoder, TextDecoder } = require('text-encoding')
api.TextDecoder = TextDecoder
api.TextEncoder = TextEncoder
}
if(!api.crypto){try{
var crypto = USE('crypto', 1);
const { TextEncoder, TextDecoder } = USE('text-encoding', 1)
Object.assign(api, {
crypto,
//subtle,
TextEncoder,
TextDecoder,
random: (len) => Buffer.from(crypto.randomBytes(len))
});
//try{