Skip to content

Instantly share code, notes, and snippets.

View JLHwung's full-sized avatar

Huáng Jùnliàng JLHwung

  • Waterloo, ON, Canada
View GitHub Profile
@JLHwung
JLHwung / stat-inlined-helper-calls.sh
Last active November 6, 2019 20:42
A shell script to stat the number of inlined _interopRequireDefault helpers
#!/bin/sh
# @babel/standalone 7.7.1
wget -qO- https://unpkg.com/@babel/[email protected]/babel.js | grep -Ec "^function \_interopRequireDefault\(obj\)"
# @babel/standalone develop
cat packages/babel-standalone/babel.js | grep -Ec "^function \_interopRequireDefault\(obj\)"
# @babel/preset-env-standalone 7.7.1
wget -qO- https://unpkg.com/@babel/[email protected]/babel-preset-env.js | grep -Ec "^function \_interopRequireDefault\(obj\)"
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = normalizeFile;
function _fs() {
const data = _interopRequireDefault(require("fs"));
@JLHwung
JLHwung / wavy-dot-representation.md
Created May 5, 2020 20:21
A wavy-dot AST representation

Extend from the ChainingExpression approach.

Expressions

ChainingExpression

extend interface Chain <: Node {
    eventual: boolean
@JLHwung
JLHwung / optional-chaining.md
Created June 2, 2020 22:17
Babel's optional chaining AST spec

Expressions

OptionalMemberExpression

interface OptionalMemberExpression <: Expression {
  type: "OptionalMemberExpression";
  object: Expression;
  property: Expression;
 computed: boolean;
@JLHwung
JLHwung / explainer.md
Last active June 10, 2020 02:08
Safari console should not apply string normalization on pasteboard content

Intro

This is an example gist repo showcasing a bug that Safari applies string normalization when pasteboard content is applied

Reproduction

curl -o- https://gist.githubusercontent.com/JLHwung/64fed33e2dbb3da7a18566fab26f045f/raw/75a7be7ac00626e58ec93a90ade70909b1bd7fe1/test.js | pbcopy
@JLHwung
JLHwung / README.md
Created January 15, 2021 15:52
Forked cluster does not fixup process.execArgv when executed by module.runMain()
node --expose_gc ./wrapper.js ./payload.js

Expected:

[Function: gc] true
[Function: gc]

Workflow:

Sort current dictionary in the order of Block > Cangjie code

node ./sort-dict.mjs /path/to/cangjie5.dict.yaml

Merge Cangjie5.txt of https://github.com/Jackchows/Cangjie5 to cangjie5.dict.yaml

node ./merge-cangjie5-txt.mjs /path/to/Cangjie5.txt /path/to/cangjie5.dict.yaml
@JLHwung
JLHwung / remove-empty-babel-parser-fixture-options.js
Created April 19, 2021 19:28
A script to remove empty options.json in babel parser fixtures
const glob = require("glob");
const fs = require("fs");
glob(
"./packages/babel-parser/test/fixtures/**/options.json",
{},
function (err, files) {
if (err) throw err;
for (const file of files) {
const contents = JSON.stringify(JSON.parse(fs.readFileSync(file)));
@JLHwung
JLHwung / set-has-bench.mjs
Created May 31, 2021 19:19
Download and run under github.com/babel/babel/packages/babel-parser/benchmark/
import Benchmark from "benchmark";
import { report } from "./util.mjs";
const suite = new Benchmark.Suite();
const reservedWords = [
"break",
"case",
"catch",
"continue",
@JLHwung
JLHwung / ast-examples.md
Last active December 25, 2022 03:01
AST examples for ESTree pattern-matching proposal

Note: The ExpressionStatement and Program node are omitted in the examples.

1. Object Match Pattern and "else" Match Clause

match (x) {
    when ({ colour: "#000000" }) { "yes" }
    else {
        "no"