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 🙏

© 2024 – Pkg Stats / Ryan Hefner

schwa

v0.13.0

Published

Schwa Lang

Downloads

4

Readme

Schwa

npm version

A toolchain written in Node for a toy language with a C-like syntax that compiles to WebAssembly.

Installation

npm install schwa --save

Usage

Module

// TypeScript and JavaScript ES6+
import { Compiler } from "schwa"
let compiler = new Compiler()
compiler.compile(inputLineArray, wasmModuleName)

// JavaScript ES5 and older
var Compiler = require('schwa').Compiler
var compiler = new Compiler()
compiler.compile(inputLineArray, wasmModuleName)

Command Line

schwa --help

Features

  • Strong Static Typing
  • Minimal C-Like Syntax
  • Opinionated Auto-Formatter
  • WASM Binary Output
  • Near Feature Parity with WebAssembly
  • Separate Type-Checked Signed/Unsigned and Boolean Types
  • Simplified Memory Access Via Memory-Mapped Structs and Arrays
  • Modular Node API
  • TypeScript Type Definitions
  • Command Line Compiler

Planned

  • VSCode Language Plugin
  • JavaScript Wrapper Generator
  • JS and Schwa Imports/Exports
  • Project-Aware Compilation
  • Formal Language Specification

Examples

Fibonacci

export int fibonacci(int n)
    if n <= 1
        return 1
    return fibonacci(n - 1) + fibonacci(n - 2)

Syntax Sample

int y = 1333 // Set up y

int hexExample = -0x80000000
uint octalExample = 0o371u
float binaryExample = 0b111.111f

export const int SOME_CONST = 5

void main()
    DoSomething(true, 23uL)

export void DoSomething(bool alphabet, ulong soup)
    int z = 10 / SOME_CONST / 1f as int
    // Initialize x
    int x = (50.0f + -20f + 2f * float.floor(20.5f)) to int |> SOME_CONST
    y = -y
    if x == 70 & SOME_CONST //Check logic
        x = ((20f + 10uL to float) * float.ceil(20.25f)) to int
        if !alphabet && x == 20
            nop()
        else if y == 70 && x > 0
            while y > 0
                y = y - 15
                if y < 0
                    break
                else
                    continue
                bool foo = true
            DoSomething(!alphabet, soup)
        else
            nop() //Null operation
        return

export int add(int a, int b)
    return a + b

export int inc()
    int val = add(int.load(0u), 1)
    int.store(0u, val)
    return val

// Accessing this struct's properties will emit loads/stores starting at address 64
map Object object at 64

export float getLength(Vector v)
    return float.sqrt(v.x * v.x + v.y * v.y)

export void normalize()
    float len = getLength(object.position)
    float x = object.position.x / len
    float y = object.position.y / len
    object.position.x = x
    object.position.y = y

export void resetColor(int i)
    object.colors[i].r = 0
    object.colors[i].g = 0
    object.colors[i].b = 0
    object.colors[i].a = 255


struct Vector
    float x // The horizontal coordinate
    float y // The vertical coordinate

struct Color
    int r
    int g
    int b
    int a

struct Object
    Vector position
    Color colors[4]

Usage and Contribution

  1. Clone the repository (git clone https://github.com/Hawkbat/Schwa)
  2. Install dependencies (npm install)
  3. Install TypeScript compiler (npm install -g typescript)
  4. Edit source code as desired
  5. Compile TypeScript source (tsc)
  6. Commit changes (git commit)
  7. Submit upstream pull request

License

MIT