MCPcopy Create free account
hub / github.com/ICBNetwork/web3-Wallet / passStringToWasm0

Function passStringToWasm0

ppom/src/ppom.js:71–107  ·  view source on GitHub ↗
(arg, malloc, realloc)

Source from the content-addressed store, hash-verified

69});
70
71function passStringToWasm0(arg, malloc, realloc) {
72
73 if (realloc === undefined) {
74 const buf = cachedTextEncoder.encode(arg);
75 const ptr = malloc(buf.length, 1) >>> 0;
76 getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
77 WASM_VECTOR_LEN = buf.length;
78 return ptr;
79 }
80
81 let len = arg.length;
82 let ptr = malloc(len, 1) >>> 0;
83
84 const mem = getUint8Memory0();
85
86 let offset = 0;
87
88 for (; offset < len; offset++) {
89 const code = arg.charCodeAt(offset);
90 if (code > 0x7F) break;
91 mem[ptr + offset] = code;
92 }
93
94 if (offset !== len) {
95 if (offset !== 0) {
96 arg = arg.slice(offset);
97 }
98 ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
99 const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
100 const ret = encodeString(arg, view);
101
102 offset += ret.written;
103 }
104
105 WASM_VECTOR_LEN = offset;
106 return ptr;
107}
108
109function isLikeNone(x) {
110 return x === undefined || x === null;

Callers 1

__wbg_get_importsFunction · 0.85

Calls 1

getUint8Memory0Function · 0.85

Tested by

no test coverage detected