Home / Function/ wasmHelper() — vite Function Reference

wasmHelper() — vite Function Reference

Architecture documentation for the wasmHelper() function in wasm.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  0d75a8a7_f26a_435d_13a5_1589846184a8["wasmHelper()"]
  d496a62e_d9d8_41d4_a984_96f1dbd5f4bd["wasm.ts"]
  0d75a8a7_f26a_435d_13a5_1589846184a8 -->|defined in| d496a62e_d9d8_41d4_a984_96f1dbd5f4bd
  1424df8c_6dcf_6693_4489_c5347c3f6f44["instantiateFromUrl()"]
  0d75a8a7_f26a_435d_13a5_1589846184a8 -->|calls| 1424df8c_6dcf_6693_4489_c5347c3f6f44
  style 0d75a8a7_f26a_435d_13a5_1589846184a8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/wasm.ts lines 15–38

const wasmHelper = async (opts = {}, url: string) => {
  let result
  if (url.startsWith('data:')) {
    const urlContent = url.replace(/^data:.*?base64,/, '')
    let bytes
    if (typeof Buffer === 'function' && typeof Buffer.from === 'function') {
      bytes = Buffer.from(urlContent, 'base64')
    } else if (typeof atob === 'function') {
      const binaryString = atob(urlContent)
      bytes = new Uint8Array(binaryString.length)
      for (let i = 0; i < binaryString.length; i++) {
        bytes[i] = binaryString.charCodeAt(i)
      }
    } else {
      throw new Error(
        'Failed to decode base64-encoded data URL, Buffer and atob are not supported',
      )
    }
    result = await WebAssembly.instantiate(bytes, opts)
  } else {
    result = await instantiateFromUrl(url, opts)
  }
  return result.instance
}

Domain

Subdomains

Frequently Asked Questions

What does wasmHelper() do?
wasmHelper() is a function in the vite codebase, defined in packages/vite/src/node/plugins/wasm.ts.
Where is wasmHelper() defined?
wasmHelper() is defined in packages/vite/src/node/plugins/wasm.ts at line 15.
What does wasmHelper() call?
wasmHelper() calls 1 function(s): instantiateFromUrl.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free