Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
use-wasm-ts
Advanced tools
Use WebAssembly in React in a simple way with hooks and Typescript!
npm install use-wasm-ts
This package allows you to load and use your WebAssembly functions inside React easily.
import { FC } from 'react';
import { useWasm } from 'use-wasm-ts';
const MyComponent: FC = () => {
const {
isLoading,
fn: { compute },
} = useWasm<{ compute: (n: number) => number }>('compute.wasm');
return (
<>
<p>{isLoading ? "Loading..." : `Loaded with ${compute(10)}`}</p>
</>
);
};
export default MyComponent;
Show a live demo on CodeSandbox.
useWasm<T>(url: string, options?: useWasmOptions): {
isLoading: boolean;
fn: T;
module: WebAssembly.Module;
instance: WebAssembly.Instance;
memory: WebAssembly.Memory;
};
Type: string
The url of the WebAssembly file.
Type: useWasmOptions
boolean
(default: false
)The streaming option allows you to load the WebAssembly file in streaming mode. Before using it, make sure that your server serves the file with the correct MIME type.
RequestInit
(default: {}
)The fetchOptions option allows you to pass options to the fetch function.
WebAssembly.Memory
(default: { initial: 256, maximum: 512 }
)The memory option allows you to pass a custom memory to the WebAssembly file.
(memory: WebAssembly.Memory) => { [key: string]: any }
(default: {}
)The env option allows you to pass a custom environment to the WebAssembly file. The function takes the default / custom memory as an optionnal parameter and must return an object.
MIT
FAQs
Use WebAssembly in React in a simple way with hooks and Typescript!
The npm package use-wasm-ts receives a total of 1 weekly downloads. As such, use-wasm-ts popularity was classified as not popular.
We found that use-wasm-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.