mirror of
https://github.com/amark/gun.git
synced 2025-06-09 15:46:44 +00:00
WIP: textencoder for RN
This commit is contained in:
parent
a2a7ef91bb
commit
0311969060
10
sea.js
10
sea.js
@ -173,14 +173,16 @@
|
|||||||
api.TextDecoder = window.TextDecoder;
|
api.TextDecoder = window.TextDecoder;
|
||||||
api.random = (len) => Buffer.from(api.crypto.getRandomValues(new Uint8Array(Buffer.alloc(len))))
|
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{
|
if(!api.crypto){try{
|
||||||
var crypto = USE('crypto', 1);
|
var crypto = USE('crypto', 1);
|
||||||
const { TextEncoder, TextDecoder } = USE('text-encoding', 1)
|
|
||||||
Object.assign(api, {
|
Object.assign(api, {
|
||||||
crypto,
|
crypto,
|
||||||
//subtle,
|
|
||||||
TextEncoder,
|
|
||||||
TextDecoder,
|
|
||||||
random: (len) => Buffer.from(crypto.randomBytes(len))
|
random: (len) => Buffer.from(crypto.randomBytes(len))
|
||||||
});
|
});
|
||||||
//try{
|
//try{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user