Skip to content

Instantly share code, notes, and snippets.

View funnbot's full-sized avatar

Dillon Bayless funnbot

  • San Francisco Bay Area
  • 13:23 (UTC -07:00)
View GitHub Profile
@ewinslow
ewinslow / classes.md
Last active January 24, 2018 04:03
How I wish ES6 classes were implemented

Introduction

ES6 classes are happening, and there's no way the syntax is going to change radically just for me this late in the game, but I still figure what the heck. Maybe I can write a language someday that has this feature. Or maybe I'm wrong and the feature can change with enough motivation...

Background

The main premise of the currently accepted syntax is to be simple sugar over the prototype style of class definitions:

function Foo() {
if (process.version.startsWith("v6")) throw new Error("This Bot requires Node 7v+ because of async/await")
const Discord = require("discord.js")
const express = require("express")
const app = express()
const superagent = require("superagent")
//Config
let INVITE = process.env.INVITE || "", //An Infinite Invite to your discord server.
GUILD = process.env.GUILD || "", //The ID of the Guild for this invite ^
@funnbot
funnbot / zig_gen_typings.js
Created June 15, 2020 03:16
Generate typescript d.ts typings from the exported functions in a zig file, useful for targeting web assembly and having autocomplete.
#!/usr/bin/env node
const fs = require('fs');
// mmm tasty regex
const definRegex = /export\s+fn\s+([A-Za-z_][A-Za-z0-9_]*)\s*\(((\s*([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.+?),?)*)\)\s*(.+?)[ \n\r{]+?/g;
const paramRegex = /\s*([A-Za-z_][A-Za-z0-9_]*)\s*:\s*([^,]+),?/g;
run(process.argv);