40 lines · 718 B · JavaScript
RawDownload
/* example of JS module importing a C module */import { Point } from "./point.so"; function assert(b, str){    if (b) {        return;    } else {        throw Error("assertion failed: " + str);    }} class ColorPoint extends Point {    constructor(x, y, color) {        super(x, y);        this.color = color;    }    get_color() {        return this.color;    }}; function main(){    var pt, pt2;     pt = new Point(2, 3);    assert(pt.x === 2);    assert(pt.y === 3);    pt.x = 4;    assert(pt.x === 4);    assert(pt.norm() == 5);     pt2 = new ColorPoint(2, 3, 0xffffff);    assert(pt2.x === 2);    assert(pt2.color === 0xffffff);    assert(pt2.get_color() === 0xffffff);} main();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t