Skip to content

Instantly share code, notes, and snippets.

View Jamesernator's full-sized avatar

James Browning Jamesernator

View GitHub Profile
async def yieldfromexample():
RESULT = yield from EXPR
# Would become
async def yieldfromexample():
_i = aiter(EXPR)
try:
_y = await anext(_i)
except StopAsyncIteration as _e:
_r = _e.value
async function drawCircles(mousedownEvent) {
const { top, left } = theCanvas.getBoundingClientRect()
for await (const clickEvent of clicks(theCanvas)) {
const radius = Math.random() * 19 + 1 // Circles between 1-20 inclusive
const color = randomColor()
drawCircle(
theCanvas,
clickEvent.clientX - left,
clickEvent.clientY - top,
radius,

Array<T>

Array<T>.prototype.*

  • concat(: (T | Array<T>)[]): T[]
    concat(items) 🔒
    • Returns a new array that is the concatenation of this and all items. Non-array parameters are treated as if they were arrays with single elements.
    • ES3
    • ['a'].concat('b', ['c', 'd']) → [ 'a', 'b', 'c', 'd' ]
  • copyWithin(:number, :number, ?:number): this
@Jamesernator
Jamesernator / steam_names
Last active July 27, 2018 13:43
This is All Names I've Gone By On Steam Since Choosing Music Names
Boris the Spider
Swamp
Dry County
White Lightning
Murder By Numbers
Dreadmonboogaloo
Expresso Love
Lizard Life
Fuzzbox Voodoo
Makin' Thunderbirds
@Jamesernator
Jamesernator / doAbortable.ts
Last active November 4, 2020 21:25
doAbortable
export default async function doAbortable<R>(
signal: AbortSignal | undefined,
func: (abortSignal: AbortSignal) => R | Promise<R>,
): Promise<R> {
const controller = new AbortController();
const abortInner = () => controller.abort();
if (signal?.aborted) {
abortInner();
} else {
signal?.addEventListener("abort", abortInner, { once: true });
@Jamesernator
Jamesernator / README.md
Last active June 16, 2022 06:28
Harden

Harden - Fixing the override mistake

The override mistake

The override mistake is a problem introduced with ES5's ability to mark properties as non-writable. When a property on the prototype of an object is marked non-writable, it makes the property unaddable on the object.

A notable example of this is if we freeze (which marks all properties as non-writable) on Object.prototype.