
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
@localinference/utils
Advanced tools
Local Inference internal utils package to avoid boilerplate across codebases.
Local Inference internal utils package to avoid boilerplate across codebases.
Uint8Array; browser runtimes need ONNX Runtime Web compatible backends such as WebNN, WebGPU, WebGL, or WebAssembly.LocalInferenceUtilsError codes.npm install @localinference/utils
# or
pnpm add @localinference/utils
# or
yarn add @localinference/utils
# or
bun add @localinference/utils
# or
deno add jsr:@localinference/utils
# or
vlt install jsr:@localinference/utils
import { GPUAccelerationSupported } from '@localinference/utils'
if (GPUAccelerationSupported()) {
console.log('Browser GPU acceleration APIs look available')
}
import { createTokenizer } from '@localinference/utils'
const tokenizer = await createTokenizer(modelBytes)
const ids = tokenizer.encodeIds('hello world')
const text = tokenizer.decodeIds(ids)
import { Tensor } from 'onnxruntime-web'
import { createInferenceSession } from '@localinference/utils'
const session = await createInferenceSession(modelBytes)
const outputs = await session.run({
input: new Tensor('float32', Float32Array.from([1]), [1]),
})
createInferenceSession() uses the onnxruntime-web runtime with the wasm execution provider. In Deno, it also forces single-threaded wasm to avoid runtime worker failures. createTokenizer() loads the serialized SentencePiece model directly from bytes.
GPUAccelerationSupported() is a heuristic boolean probe for browser and browser-worker contexts. It checks for WebNN, WebGPU, and WebGL. createInferenceSession() only loads onnxruntime-web/all and prefers webnn, webgpu, webgl, then wasm when that probe returns true. Otherwise it stays on the wasm path. Browser builds must make the ONNX Runtime Web wasm assets reachable to the app.
This package is smoke-tested in a service-worker-style edge runtime through edge-runtime. That coverage verifies that the package loads, GPUAccelerationSupported() returns false, and createInferenceSession() selects the wasm-only path instead of browser GPU providers.
That is narrower than full cross-platform inference support. Real ONNX execution still depends on each edge platform's WebAssembly loading model and asset rules, so Cloudflare Workers, Vercel Edge, and similar runtimes should still be validated in the exact deployment target before being treated as a production inference environment.
Failures are wrapped in LocalInferenceUtilsError with stable code values:
TOKENIZER_MODEL_LOAD_FAILEDINFERENCE_SESSION_CREATE_FAILEDThe original dependency error is preserved as error.cause.
This package does not cache tokenizers or inference sessions. Each call creates a fresh runtime object.
npm testnode test/run-coverage.mjs100% statements, branches, functions, and linesGPUAccelerationSupported() / wasm-path smoke)Pixel 5)iPhone 12)22.x and 24.xnpm test builds the package, runs the node:test unit/integration suite under c8, then runs the end-to-end smoke suite against the built package across the ESM/CJS/runtime matrix above.
npm run benchNode v22.14.0 (win32 x64)7.9 ops/s (127.049 ms/op)48509.3 ops/s (0.021 ms/op)10.6 ops/s (94.519 ms/op)8891.1 ops/s (0.112 ms/op)Results vary by machine.
Apache-2.0
FAQs
Local Inference internal utils package to avoid boilerplate across codebases.
The npm package @localinference/utils receives a total of 7 weekly downloads. As such, @localinference/utils popularity was classified as not popular.
We found that @localinference/utils demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.