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

Function passStringToWasm0

packages/databus-wasm-web/databus_wasm.js:58–94  ·  view source on GitHub ↗
(arg, malloc, realloc)

Source from the content-addressed store, hash-verified

56});
57
58function passStringToWasm0(arg, malloc, realloc) {
59
60 if (realloc === undefined) {
61 const buf = cachedTextEncoder.encode(arg);
62 const ptr = malloc(buf.length, 1) >>> 0;
63 getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
64 WASM_VECTOR_LEN = buf.length;
65 return ptr;
66 }
67
68 let len = arg.length;
69 let ptr = malloc(len, 1) >>> 0;
70
71 const mem = getUint8Memory0();
72
73 let offset = 0;
74
75 for (; offset < len; offset++) {
76 const code = arg.charCodeAt(offset);
77 if (code > 0x7F) break;
78 mem[ptr + offset] = code;
79 }
80
81 if (offset !== len) {
82 if (offset !== 0) {
83 arg = arg.slice(offset);
84 }
85 ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
86 const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
87 const ret = encodeString(arg, view);
88
89 offset += ret.written;
90 }
91
92 WASM_VECTOR_LEN = offset;
93 return ptr;
94}
95
96function isLikeNone(x) {
97 return x === undefined || x === null;

Callers 11

get_recordsFunction · 0.70
constructorMethod · 0.70
delete_cacheMethod · 0.70
get_datasheet_packMethod · 0.70
json0_createMethod · 0.70
json0_applyMethod · 0.70
json0_transformMethod · 0.70
json0_transform_xMethod · 0.70
json0_invertMethod · 0.70
json0_composeMethod · 0.70
__wbg_get_importsFunction · 0.70

Calls 3

getUint8Memory0Function · 0.70
encodeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected