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

Function passStringToWasm0

packages/databus-wasm-nodejs/cjs/databus_wasm.js:61–97  ·  view source on GitHub ↗
(arg, malloc, realloc)

Source from the content-addressed store, hash-verified

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

Callers 10

databus_wasm.jsFile · 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

Calls 3

getUint8Memory0Function · 0.70
encodeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected