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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cooljapan/oxirs

v0.2.2

Published

WebAssembly bindings for OxiRS - Run RDF/SPARQL in the browser

Readme

oxirs-wasm

WebAssembly bindings for OxiRS - Run RDF/SPARQL in the browser

Crates.io docs.rs npm

Lightweight RDF and SPARQL implementation compiled to WebAssembly for browser, Node.js, and edge deployment.

Features

  • In-memory RDF Store: HashSet-based triple storage with O(1) lookups
  • RDF Parsing: Turtle and N-Triples format support
  • SPARQL Queries: SELECT, ASK, CONSTRUCT with pattern matching
  • TypeScript Support: Full type definitions
  • Zero Server Dependencies: No Tokio, runs in single-threaded WASM
  • Lightweight: ~300KB optimized binary

Installation

NPM (Browser/Node.js)

npm install oxirs-wasm

Cargo (Rust WASM Project)

[dependencies]
oxirs-wasm = "0.1"

Quick Start

JavaScript/TypeScript

import { initialize, createStore } from 'oxirs-wasm';

// Initialize WASM module
await initialize();

// Create RDF store
const store = await createStore();

// Load Turtle data
const turtle = `
    @prefix : <http://example.org/> .
    :alice :knows :bob .
    :bob :name "Bob" .
`;
const count = await store.loadTurtle(turtle);
console.log(`Loaded ${count} triples`);

// Execute SPARQL query
const results = await store.query(`
    SELECT ?person ?name WHERE {
        ?person :name ?name .
    }
`);
console.log(results);
// [{ person: "http://example.org/bob", name: "\"Bob\"" }]

// ASK query
const exists = await store.ask(`
    ASK { :alice :knows :bob }
`);
console.log('Alice knows Bob:', exists); // true

// Export to N-Triples
const ntriples = store.toNTriples();
console.log(ntriples);

HTML Integration

<!DOCTYPE html>
<html>
<head>
    <title>RDF in Browser</title>
</head>
<body>
    <script type="module">
        import { initialize, createStore } from './pkg/oxirs_wasm.js';

        async function run() {
            await initialize();
            const store = await createStore();

            await store.loadTurtle(`
                @prefix : <http://example.org/> .
                :alice :knows :bob .
            `);

            const results = await store.query(
                'SELECT ?s ?o WHERE { ?s :knows ?o }'
            );

            console.log('Results:', results);
        }

        run();
    </script>
</body>
</html>

Building from Source

# Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

# Build WASM package
cd platforms/oxirs-wasm
wasm-pack build --target web --release

# The output will be in pkg/
# - oxirs_wasm.js (ES module)
# - oxirs_wasm_bg.wasm (binary)
# - oxirs_wasm.d.ts (TypeScript types)

API Reference

Store Operations

class OxiRSStore {
    constructor();

    // Load RDF data
    loadTurtle(turtle: string): Promise<number>;
    loadNTriples(ntriples: string): Promise<number>;

    // Triple operations
    insert(subject: string, predicate: string, object: string): boolean;
    delete(subject: string, predicate: string, object: string): boolean;
    contains(subject: string, predicate: string, object: string): boolean;
    size(): number;
    clear(): void;

    // SPARQL queries
    query(sparql: string): Promise<QueryResult[]>;
    ask(sparql: string): Promise<boolean>;
    construct(sparql: string): Promise<Triple[]>;

    // Export
    toTurtle(): string;
    toNTriples(): string;

    // Indexes
    subjects(): string[];
    predicates(): string[];
    objects(): string[];

    // Namespaces
    addPrefix(prefix: string, uri: string): void;
}

Deployment Targets

Browser

<script type="module">
    import init, { createStore } from './pkg/oxirs_wasm.js';
    await init();
    const store = await createStore();
</script>

Node.js

const { initialize, createStore } = require('oxirs-wasm');

(async () => {
    await initialize();
    const store = await createStore();
    // ...
})();

Cloudflare Workers

import { initialize, createStore } from 'oxirs-wasm';

export default {
    async fetch(request: Request): Promise<Response> {
        await initialize();
        const store = await createStore();

        // Process RDF data
        const { rdf, sparql } = await request.json();
        await store.loadTurtle(rdf);
        const results = await store.query(sparql);

        return new Response(JSON.stringify(results));
    }
};

Deno Deploy

import { initialize, createStore } from 'https://esm.sh/oxirs-wasm';

Deno.serve(async (req) => {
    await initialize();
    const store = await createStore();
    // ...
});

Limitations

Current implementation focuses on core functionality:

  • ❌ No persistent storage (in-memory only)
  • ❌ No SPARQL UPDATE/DESCRIBE
  • ❌ No RDFS/OWL reasoning
  • ❌ No SHACL validation
  • ❌ No federated queries (SERVICE)
  • ❌ Limited SPARQL features (basic graph patterns only)

For full SPARQL support, use the server-side oxirs-fuseki crate.

Performance

  • WASM binary size: ~300KB (optimized with wasm-opt)
  • Initialization: ~100ms (first load, cached)
  • Parsing: 10K triples/sec (Turtle)
  • Query execution: 1K queries/sec (simple patterns)
  • Memory: ~200KB per 1K triples

Use Cases

  • Browser RDF Editors: Client-side validation and editing
  • Offline Applications: Local knowledge graphs without server
  • Edge Computing: IoT devices, embedded systems
  • Privacy-Preserving: Process sensitive data locally
  • Developer Tools: RDF/SPARQL playground in browser
  • Static Sites: Jamstack with client-side queries

Dependencies

  • wasm-bindgen - JavaScript interop
  • js-sys - JavaScript standard library bindings
  • web-sys - Web APIs (console, performance)
  • getrandom - Random number generation (js feature)

License

Licensed under the Apache License, Version 2.0.