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

@junioradevteam/web-cpp

v0.8.1

Published

a c++ compiler in typescript

Readme

web-cpp

Build Status Coverage Status

A experimental c++ compiler in typescript

online demo => zurl.github.io/web-cpp

Introduction

This project is a In-browser C++ Compiler and Runtime toolchains, which requires no server and could run in all major browsers.

Our compiler could compile C++ to WebAssembly, which is a low-level programming language. WebAssembly is supported by most browsers currently, it is much more faster than JavaScript, and able to be compiled from all static languages.

LLVM provides excellent support of WebAssembly Backend, our compiler is inspired by them and learned a lot from its good design.

Our Compiler and Runtime is much more fast than all C++ interpreter in browser, the c++ code will be compiled directly to WebAssembly, and WebAssembly will be executed by high performance JIT execution engine in our browser. According to our experiment, our compiler could have nearly same performance to gcc/g++ without optimization.

How to Use

  1. build web-cpp compiler itself
npm install
npm run build
npm run test
  1. build the web-cpp online ide

we use parcel as our packager, you could use any kind of web packager with your custom configuration.

npm run build
cd ide
parcel build index.html

How to develop/extend

Our Compiler is designed as a loosely coupled, componentized compiler, so it is easy for you to extend or further develop our compiler system.

Write Javascript Library

The Javascript Library in our library is called "syscall", which is similar to UNIX syscall concept.

Before you add new JavaScript syscall, you should write a header file in resource/libstdcpp/include, you could extend or create new cpp file in the directory. The syntax is similar to ordinary C++ function declaration, but you need a __libcall prefix before your declaration.

The syscall code is located in src/library/syscall.ts, please just write plain js function (not arrow function) that receive js number and return js number or none. The this pointer of js function will be WASM runtime, you could access C++ Virtual Machine via this pointer, string could be pass by memory address.

After any modification, please run npm run build to refresh the binary library file.

Write C++ Library

Similarly, Library in C++ is also supported by our system, your need to add .h file in resource/libstdcpp/include and .cpp file in resource/libstdcpp/lib, our compiler will automatically load these files if you build the compiler.

After any modification, please run npm run build to refresh the binary library file.

Add new C++ Grammar

Our grammar files are located in resource/grammar, it is divided into several files for readability, the file are in parsing expression grammar which supported by PEG.js(https://pegjs.org/), you could write your own rules to extend our compiler.

After any modification, please run npm run build to refresh the binary parser file.

Using WebAssembly Backend

Our compiler has a high-level abstraction of WebAssembly AST, which located in src/wasm directory,

The WASM AST is abstracted in a tree-like structure, the hierarchy is WModule -> WSection -> WStatement -> WExpression WExpression is the minimal unit of WASM AST, it could emit a return value, and consume by WStatement. WStatements contains several control flow structure, and several WStatements will be composed to a WCodeSection.

For other WSection, you could refer to the official standard of WebAssembly.

Roadmap

Version

  • [X] 0.4 Classic C with class support
  • [X] 0.5 With interpreter runtime
  • [X] 0.6 With function template
  • [X] 0.7 With class template
  • [X] 0.8 With std library (some)

C language

  • [X] function call codegen / return codegen
  • [X] & && | || >> <<
  • [X] ++ --
  • [X] + - ! ~
  • [X] += -= *= /= ...
  • [X] vm
  • [X] array
  • [X] sizeof
  • [X] typedef
  • [X] union
  • [X] js native function
  • [X] string
  • [X] var initializer
  • [X] data segment data
  • [X] doConstant about < > <= >= == & && | || >> << ...
  • [X] struct / class
  • [X] cast ope (hard)
  • [X] void return type;
  • [X] function call parameter type conversion
  • [X] var args
  • [X] allocator
  • [X] char * a = "123"
  • [X] write, read
  • [X] printf
  • [X] postfix ++ --
  • [X] do-while
  • [X] break continue
  • [deprecated] goto label
  • [X] switch case
  • [X] enum
  • [X] non-return detect
  • [X] js highlevel api
  • [X] constant fold on tree
  • [X] init instructions
  • [X] print sourceMap
  • [X] cc-cli
  • [X] local address
  • [X] const
  • [X] malloc need
  • [X] & array alias
  • [X] &
  • [X] int64
  • [X] ?:
  • [X] function pointer
  • [X] array initial list
  • [X] multi-dim array
  • [X] bit field of struct
  • [X] #if #elif
  • [X] #line line file
  • [X] debuginfo

C++ Language

  • [X] default parameter
  • [X] default constructor
  • [X] copy-constructor(use memcpy)
  • [X] temporary object destruction
  • [X] destructor
  • [X] left reference
  • [X] static member variable
  • [X] A a(c,d)
  • [X] ctor
  • [X] inner scope
  • [X] DTOR
  • [X] ctor initialize list
  • [X] copy-ctor
  • [X] copy-assignment-ctor
  • [X] static member function
  • [X] member function
  • [X] function overload
  • [X] member function overload
  • [X] __cxx_global_var_init
  • [X] inherit
  • [X] operator overload => working, bin->ok, unary->working, syntax
  • [X] implicit this
  • [X] public/private/ protect, access control (syntax ok, todo)
  • [X] new/delete
  • [X] new array []
  • [X] using
  • [X] namespace
  • [X] virtual member function
  • [not support by wasm] exception handling
  • [X] function template
  • [X] member function template in class
  • [X] class template
  • [X] mangled/demangled
  • [X] template class in template class
  • [X] template member function

TODO LIST

High
  • [X] repetitive param name detect

  • [X] cast overload, like if(object) { ... }

  • [X] warning

  • [X] class specialization

  • [X] using template

  • [X] A a[50] decons

  • [X] subclass B A::a => set children?

  • [X] explicit class ins

  • [X] placement new

  • [X] C std lib

  • [X] C++ std lib

  • [X] iostream

  • [X] string

  • [X] vector

  • [X] map

  • [X] queue/stack

  • [X] priority_queue

  • [X] algorithm

  • [X] id could not be keyword => special judge

  • [X] operator []

  • [x] operator ()

  • [X] static_cast / dynamic_cast / reinterpret_cast

  • [X] const left value reference ====== the upper is all plan of web-cpp in 2019

    Other

  • [X] const/override member function

  • [X] real const

  • [X] real override

  • [X] real accessControl

  • [X] separate define class function

  • [X] separate declaration => to be test

  • [X] typeinfo

  • [X] virtual inherit

ide

  • [X] multi-language
  • [X] config
  • [X] help

Miscellaneous

This project is my thesis of my bachelor's degree, which is inspired by the rapid development of online programming education. This project is targeted to improve the C++ learning experience for new students, thanks to everyone who helps me in the development of this project.