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

Function passStringToWasm0

packages/databus-wasm-nodejs/esm/databus_wasm_bg.js:64–100  ·  view source on GitHub ↗
(arg, malloc, realloc)

Source from the content-addressed store, hash-verified

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

Callers 15

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
__wbindgen_string_getFunction · 0.70

Calls 3

getUint8Memory0Function · 0.70
encodeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected