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

@nyar/typescript

v0.0.0

Published

> Rusty TypeScript WASI Frontend Package ๐Ÿฆ€๐ŸŒ๐Ÿ“ฆ

Readme

@nyar/typescript

Rusty TypeScript WASI Frontend Package ๐Ÿฆ€๐ŸŒ๐Ÿ“ฆ

npm TypeScript WASI


๐Ÿ“‹ Introduction

This is the WASI frontend package for Rusty TypeScript, providing the ability to load, initialize, and use the Rusty TypeScript WASM module in both browser and Node.js environments.

โœจ Core Features

| Feature | Description | Status | |---------|-------------|--------| | ๐ŸŒ WASM Loading | Automatic loading and initialization of WASM module | โœ… Available | | ๐Ÿ”ง TypeScript API | Complete type definition support | โœ… Available | | ๐Ÿ–ฅ๏ธ Multi-Environment | Supports both browser and Node.js | โœ… Available | | ๐ŸŽฎ Playground | Interactive code execution | ๐Ÿšง Planned | | ๐Ÿ“ฆ Modular | ESM / CJS dual format support | โœ… Available |


๐Ÿš€ Quick Start

Installation

# Using pnpm (recommended)
pnpm add @nyar/typescript

# Using npm
npm install @nyar/typescript

# Using yarn
yarn add @nyar/typescript

Basic Usage

import { RustyTypeScript } from '@nyar/typescript';

async function main() {
  // ๐Ÿš€ Initialize Rusty TypeScript
  const rts = await RustyTypeScript.init();
  
  // ๐Ÿ“ Execute TypeScript code
  const result = await rts.execute(`
    const greeting: string = "Hello from WASM! ๐Ÿฆ€";
    console.log(greeting);
    greeting
  `);
  
  console.log('โœ… Execution result:', result);
}

main().catch(console.error);

Browser Environment

<!DOCTYPE html>
<html>
<head>
  <title>Rusty TypeScript Playground</title>
</head>
<body>
  <div id="output"></div>
  <script type="module">
    import { RustyTypeScript } from '@nyar/typescript';
    
    async function init() {
      const output = document.getElementById('output');
      
      try {
        // ๐ŸŒ Initialize in browser
        const rts = await RustyTypeScript.init({
          wasmUrl: './typescript.wasm'
        });
        
        // Execute code
        const result = await rts.execute(`
          const fib = (n: number): number => {
            if (n <= 1) return n;
            return fib(n - 1) + fib(n - 2);
          };
          fib(10)
        `);
        
        output.innerHTML = `๐ŸŽ‰ Result: ${result}`;
      } catch (err) {
        output.innerHTML = `โŒ Error: ${err.message}`;
      }
    }
    
    init();
  </script>
</body>
</html>

Node.js Environment

import { RustyTypeScript } from '@nyar/typescript';
import { readFileSync } from 'fs';

async function runScript(filePath: string) {
  // ๐Ÿ–ฅ๏ธ Initialize in Node.js
  const rts = await RustyTypeScript.init({
    wasmModule: readFileSync('./typescript.wasm')
  });
  
  // Read and execute file
  const code = readFileSync(filePath, 'utf-8');
  const result = await rts.execute(code);
  
  console.log('โœ… Execution completed:', result);
  return result;
}

runScript('./script.ts');

๐Ÿ’ก Usage Examples

Code Editor Integration

import { RustyTypeScript } from '@nyar/typescript';
import MonacoEditor from '@monaco-editor/react';

function Playground() {
  const [output, setOutput] = useState('');
  const [rts, setRts] = useState<RustyTypeScript | null>(null);
  
  useEffect(() => {
    // Initialize
    RustyTypeScript.init().then(setRts);
    
    return () => {
      rts?.dispose();
    };
  }, []);
  
  const runCode = async (code: string) => {
    if (!rts) return;
    
    try {
      const result = await rts.execute(code);
      setOutput(JSON.stringify(result.value, null, 2));
    } catch (err) {
      setOutput(`โŒ Error: ${err.message}`);
    }
  };
  
  return (
    <div>
      <MonacoEditor
        language="typescript"
        onChange={(value) => runCode(value || '')}
      />
      <pre>{output}</pre>
    </div>
  );
}

Custom Console

import { RustyTypeScript } from '@nyar/typescript';

const customConsole = {
  log: (...args: unknown[]) => {
    // Send to logging service
    logService.info(args.join(' '));
  },
  error: (...args: unknown[]) => {
    logService.error(args.join(' '));
  },
  warn: (...args: unknown[]) => {
    logService.warn(args.join(' '));
  }
};

const rts = await RustyTypeScript.init({
  console: customConsole
});

Error Handling

import { RustyTypeScript, RustyTypeScriptError } from '@nyar/typescript';

async function safeExecute(code: string) {
  const rts = await RustyTypeScript.init();
  
  try {
    return await rts.execute(code);
  } catch (err) {
    if (err instanceof RustyTypeScriptError) {
      switch (err.type) {
        case 'syntax':
          console.error(`Syntax error (line ${err.location?.line}):`, err.message);
          break;
        case 'type':
          console.error('Type error:', err.message);
          break;
        case 'runtime':
          console.error('Runtime error:', err.message);
          break;
      }
    }
    throw err;
  }
}

๐Ÿ”ง Configuration

Vite Configuration

// vite.config.ts
import { defineConfig } from 'vite';
import wasm from 'vite-plugin-wasm';

export default defineConfig({
  plugins: [wasm()],
  optimizeDeps: {
    exclude: ['@nyar/typescript']
  },
  server: {
    headers: {
      'Cross-Origin-Opener-Policy': 'same-origin',
      'Cross-Origin-Embedder-Policy': 'require-corp'
    }
  }
});

๐Ÿงช Development

# Install dependencies
pnpm install

# Development mode
pnpm dev

# Build
pnpm build

# Test
pnpm test

# Type check
pnpm typecheck

๐Ÿ“ฆ Dependencies

| Dependency | Description | Type | |------------|-------------|------| | (no runtime dependencies) | - | - | | typescript | Type checking | dev | | vite | Build tool | dev | | vitest | Test framework | dev | | @types/node | Node.js types | dev |


๐Ÿค Contributing

We welcome Issues and PRs! Please ensure:

  1. โœ… Code passes pnpm lint
  2. โœ… Code passes pnpm typecheck
  3. โœ… All tests pass with pnpm test
  4. โœ… Both browser and Node.js environments are tested

๐Ÿ“„ License

MIT License - See LICENSE


๐Ÿฆ€ Run Rust-compiled TypeScript in your browser for ultimate performance ๐Ÿš€