npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@stevenleep/wasm-loader

v0.0.9

Published

## 安装 ```bash pnpm add @stevenleep/wasm-loader ```

Readme

@stevenleep/wasm-loader

安装

pnpm add @stevenleep/wasm-loader

如果你需要在dokant的其他包中安装wasm-loader作为依赖,你可以使用以下命令:

pnpm add -F <package> @stevenleep/wasm-loader

使用

// loadWasm在为未检测到缓存的情况下,默认使用instantiateStreaming加载wasm文件
import { loadWasm } from '@stevenleep/wasm-loader';

/**
 * 此案例通过golang构建的wasm文件,使用wasm_exec.js作为wasm的执行环境
 * 导入后将会在 Window 对象上挂载 Go 对象, 通过 new Go.run() 方法执行wasm文件
 * 也可参考这个仓库案例:https://e.gitee.com/doactionpro/repos/doactionpro/gowasm-simple-demo/blob/main/site/index.html
 * 
 * ##为什么需要这个?
 * - 参考:https://developer.mozilla.org/en-US/docs/WebAssembly/JavaScript_interface/instantiateStreaming_static#importobject
 */
import "./path/to/wasm/wasm_exec";

const loadwasmOption = new globalThis.Go();
const onProgress = (progress: ProgressResult) => {
  console.log('progress:', progress);
  console.log('progress:', progress.loaded, progress.total);
  console.log('progress:', progress.progress, progress.done);
};

const cacheOptions = {
    enable: true, // 开启wasm缓存
    set(value: Promise<ArrayBuffer>): void {
        // 自定义缓存wasm文件的方法
    },
    // 自定义获取缓存wasm文件的方法
    get(): ArrayBuffer | Promise<ArrayBuffer> | null | Promise<null> {},
}

loadWasm('path/to/wasm/file.wasm', loadwasmOption, onProgress, cacheOptions)
    .then((result) => {
        console.log('wasm loaded:', result);
        // result.add(1, 2); // 调用你的wasm函数
    })
    .catch((error) => {
        console.error('wasm load error:', error);
    });

API

loadWasm(path: string, wasmLoadOption: LoadwasmOption, onProgress?: (progress: number) => void, cacheOptions?: CacheOptions): Promise<WebAssembly.ResultObject>

  • path: string wasm文件路径
  • wasmLoadOption: LoadwasmOption, wasm加载配置, 包含以下属性, 默认 {}
    • importObject?: WebAssembly.Imports;
    • run?: Run;
  • onProgress: onProgress(progress: ProgressResult): void 加载进度回调函数
  • cacheOptions CacheOptions: wasm缓存配置, 包含以下属性, 默认 {}
    • enable: boolean; // 是否开启wasm缓存
    • set(value: Promise): void; // 自定义缓存wasm文件的方法
    • get(): ArrayBuffer | Promise | null | Promise; // 自定义获取缓存wasm文件的方法