This content moved here: https://exploringjs.com/impatient-js/ch_arrays.html#quickref-arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handler = { | |
get(target, propKey, receiver) { | |
if (/^_[0-9]+$/.test(propKey)) { | |
const result = []; | |
const first = Number(receiver); | |
const last = Number(propKey.slice(1)); | |
for (let i=first; i<=last; i++) { | |
result.push(i); | |
} | |
return result; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Tuple2<A, B> = [A, B]; | |
export type Tuple3<A, B, C> = [A, B, C]; | |
export type Tuple4<A, B, C, D> = [A, B, C, D]; | |
export type Tuple5<A, B, C, D, E> = [A, B, C, D, E]; | |
export type Tuple6<A, B, C, D, E, F> = [A, B, C, D, E, F]; | |
export type Tuple7<A, B, C, D, E, F, G> = [A, B, C, D, E, F, G]; | |
export type Tuple8<A, B, C, D, E, F, G, H> = [A, B, C, D, E, F, G, H]; | |
export type Tuple9<A, B, C, D, E, F, G, H, I> = [A, B, C, D, E, F, G, H, I]; | |
export type Tuple10<A, B, C, D, E, F, G, H, I, J> = [A, B, C, D, E, F, G, H, I, J]; |
- Documentation: https://web.dev/articles/eventsource-basics
- Use case: broadcasting data from server to browsers
- Benefits:
- Easy to understand and implement (only a few lines of code)
- No library is needed
- Can use same HTTP(S) authentication as elsewhere in the app (which can’t be done with websockets)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import invariant from "tiny-invariant"; | |
class AmalgoBox extends HTMLElement { | |
get input() { | |
return this.querySelector("input") as HTMLInputElement; | |
} | |
get button() { | |
return this.querySelector("button") as HTMLButtonElement; | |
} |
OlderNewer