MCPcopy Create free account
hub / github.com/apitable/apitable / passStringToWasm0

Function passStringToWasm0

packages/databus-wasm-web/databus_wasm_bg.js:77–113  ·  view source on GitHub ↗
(arg, malloc, realloc)

Source from the content-addressed store, hash-verified

75});
76
77function passStringToWasm0(arg, malloc, realloc) {
78
79 if (realloc === undefined) {
80 const buf = cachedTextEncoder.encode(arg);
81 const ptr = malloc(buf.length, 1) >>> 0;
82 getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
83 WASM_VECTOR_LEN = buf.length;
84 return ptr;
85 }
86
87 let len = arg.length;
88 let ptr = malloc(len, 1) >>> 0;
89
90 const mem = getUint8Memory0();
91
92 let offset = 0;
93
94 for (; offset < len; offset++) {
95 const code = arg.charCodeAt(offset);
96 if (code > 0x7F) break;
97 mem[ptr + offset] = code;
98 }
99
100 if (offset !== len) {
101 if (offset !== 0) {
102 arg = arg.slice(offset);
103 }
104 ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
105 const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
106 const ret = encodeString(arg, view);
107
108 offset += ret.written;
109 }
110
111 WASM_VECTOR_LEN = offset;
112 return ptr;
113}
114
115const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
116

Callers 8

ping_2Function · 0.70
get_recordsFunction · 0.70
constructorMethod · 0.70
get_datasheet_packMethod · 0.70
__wbindgen_string_getFunction · 0.70
__wbindgen_debug_stringFunction · 0.70

Calls 3

getUint8Memory0Function · 0.70
encodeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected