Skip to content

Instantly share code, notes, and snippets.

gimme elixir!

Darien Maillet Valentine bathos

gimme elixir!
Block or report user

Report or block bathos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
bathos / acorn-nullish-coalescing-and-optional-chaining.mjs
Created Mar 18, 2020
View acorn-nullish-coalescing-and-optional-chaining.mjs
export default function acornSkullFishKoalaCaressingAndNonstopSpinalDraining(Parser) {
const tt = Parser.acorn.tokTypes;
const ocToken = new Parser.acorn.TokenType('?.');
const ncToken = new Parser.acorn.TokenType('??', {
beforeExpr: true,
binop: 2.5
return class extends Parser {
getTokenFromCode(codePoint) {
bathos / observing-last-index-values.js
Created Dec 30, 2019
View observing-last-index-values.js
function matchAllButUpdateOriginalRegExp(regExp, string) {
return regExp[Symbol.matchAll].call({
constructor: { [Symbol.species]: function() { return regExp; } },
flags: regExp.flags,
lastIndex: regExp.lastIndex
}, string);
const pattern = /./g;
View home-obj.js
class Foo extends Bar {
method() {
const homeObject = Foo.prototype;
const superReferenceBase = Object.getPrototypeOf(homeObject);
static method() {
const homeObject = Foo;
const superReferenceBase = Object.getPrototypeOf(homeObject);
bathos /
Last active Dec 12, 2019

Trying to understand what accounts for "\8" and "\9" being considered valid string literals with identity escapes in Chrome and FF.

Annex B permits sloppy mode to include legacy octal escapes in strings. It achieves this by replacing the ‘normal’ (strict) EscapeSequence production with a new version accompanied by three new productions.

In the sloppy version, three of the alternatives are the same. The change is replacing this rule:

"0" [lookahead ∉ DecimalDigit]

bathos / weekdata.mjs
Last active Dec 7, 2019
View weekdata.mjs
import range from '/util/iterator/range.mjs';
// Week start data pulled from similarly golfed answer on SO:
// I’m not thrilled with this; we probably ought to be generating it since the
// data is pretty obscure. OTOH I’d be far less thrilled with loading hefty
// chunks of ICU data and this is pretty solid and compact!
// Note that the RegExp given for lang tags in that answer is a bit off. The one
bathos / throwing-into-iterated-async-gen.js
Created Dec 1, 2019
View throwing-into-iterated-async-gen.js
void async function() {
const asyncGenerator = async function *() { try { yield; } catch {} }();
try {
for await (const value of asyncGenerator) {
await asyncGenerator.throw(new Error);
} catch {
bathos /
Created Apr 8, 2018
FK Cstr TM: Lexical TM: Global / Strict
normal cstr - function() {}; new Function
normal no () => {} x() {}
classConstructor cstr - class {}
classConstructor no - -
generator cstr - -
generator no - function * () {}; * x() {}
async cstr - -
async no async () => {} async function() {}; async x() {}
bathos /
Last active Mar 22, 2018

When Strings Attack

The Enduring Legacy of a Very Naughty Hack from 1995 / A Bit of Intl

This is my first attempt at a tech talk thing. The focus here is strings in ES. First we’ll talk about what a string is in ES, then some of the consequences that fall out of that (a few aren’t super obvious), and finally some of the cool tools available for working with strings safely & effectively. Because of the nature of the subject we’ll also get into some more general information about Unicode, encodings and broad concepts related to strings and language.

bathos / find-a-thingie-somewhere-in-the-infinite-expanse-of-domland.js
Last active Jan 15, 2018
find a thingie somewhere in the infinite expanse of domland
View find-a-thingie-somewhere-in-the-infinite-expanse-of-domland.js
search = (() => {
const INDEX = /^(?:0|[1-9]\d+)$/;
let IDENT;
try {
IDENT = /^[\$_\p{ID_Start}][\$_\u200C\u200D\p{ID_Continue}]*$/u;
} catch (err) {
IDENT = /^[\$_a-z][\$_a-z\d]*$/i;
bathos / debouncing-promises.js
Last active Nov 8, 2017
View debouncing-promises.js
// Typically "debouncing" means limiting execution frequency by a specific
// interval while still guaranteeing that, after a call, the behavior will still
// execute (just not synchronously; the relationship is many->one for "calls" to
// "executions"). However it is sometimes desireable to not limit by a specific
// time — you may just want to prevent something from recurring concurrently,
// without concern for overall frequency. In these cases, you may instead want
// to debounce "against" promises. This function accepts a method that returns a
// promise and returns a new function that will execute that method immediately
// only when the last execution’s promise remains unresolved, and otherwise will
// queue for re-execution (once) when the current execution is complete. In all
You can’t perform that action at this time.