@swc/wasm
Advanced tools
Comparing version 1.2.39 to 1.2.40
@@ -7,3 +7,3 @@ { | ||
"description": "wasm module for swc", | ||
"version": "1.2.39", | ||
"version": "1.2.40", | ||
"license": "Apache-2.0/MIT", | ||
@@ -10,0 +10,0 @@ "repository": { |
60
wasm.js
let imports = {}; | ||
imports['__wbindgen_placeholder__'] = module.exports; | ||
let wasm; | ||
const { TextDecoder } = require(String.raw`util`); | ||
const { TextDecoder, TextEncoder } = require(String.raw`util`); | ||
@@ -41,16 +41,52 @@ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
let cachegetNodeBufferMemory0 = null; | ||
function getNodeBufferMemory0() { | ||
if (cachegetNodeBufferMemory0 === null || cachegetNodeBufferMemory0.buffer !== wasm.memory.buffer) { | ||
cachegetNodeBufferMemory0 = Buffer.from(wasm.memory.buffer); | ||
} | ||
return cachegetNodeBufferMemory0; | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' | ||
? function (arg, view) { | ||
return cachedTextEncoder.encodeInto(arg, view); | ||
} | ||
: function (arg, view) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
view.set(buf); | ||
return { | ||
read: arg.length, | ||
written: buf.length | ||
}; | ||
}); | ||
function passStringToWasm0(arg, malloc) { | ||
function passStringToWasm0(arg, malloc, realloc) { | ||
const len = Buffer.byteLength(arg); | ||
const ptr = malloc(len); | ||
getNodeBufferMemory0().write(arg, ptr, len); | ||
WASM_VECTOR_LEN = len; | ||
if (realloc === undefined) { | ||
const buf = cachedTextEncoder.encode(arg); | ||
const ptr = malloc(buf.length); | ||
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf); | ||
WASM_VECTOR_LEN = buf.length; | ||
return ptr; | ||
} | ||
let len = arg.length; | ||
let ptr = malloc(len); | ||
const mem = getUint8Memory0(); | ||
let offset = 0; | ||
for (; offset < len; offset++) { | ||
const code = arg.charCodeAt(offset); | ||
if (code > 0x7F) break; | ||
mem[ptr + offset] = code; | ||
} | ||
if (offset !== len) { | ||
if (offset !== 0) { | ||
arg = arg.slice(offset); | ||
} | ||
ptr = realloc(ptr, len, len = offset + arg.length * 3); | ||
const view = getUint8Memory0().subarray(ptr + offset, ptr + len); | ||
const ret = encodeString(arg, view); | ||
offset += ret.written; | ||
} | ||
WASM_VECTOR_LEN = offset; | ||
return ptr; | ||
@@ -57,0 +93,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12689763
184