// Herencia por prototipado
var a = Object.create(null) // Esta es la única forma de crear un objeto sin prototipo
a.__proto__ === null
var b = Object.create(a)
b.__proto__ === a // true
a.x = 5
b.x // 5, la propiedad `x` se busca primero en `b` y luego en `b.__proto__`
b.x = 6
b.x // 6, la propiedad `x` se busca en `b`
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
// Supongamos que tenemos una función para ver si dos cosas son *estructuralmente* iguales: | |
// (Sí tenemos una función así, en algún `utils.ts`) | |
function equals(a, b) { | |
// Implementación sumamente ineficiente pero que sirve para este ejemplo | |
return JSON.stringify(a) === JSON.stringify(b); | |
} | |
// El `...` significa algo distinto cuando se |
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
module Utils.NodeId exposing (NodeId, child, root, toZipper) | |
import Tree exposing (Tree) | |
import Tree.Zipper as Zipper exposing (Zipper) | |
--- NODE ID | |
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 numbers = | |
input | |
.trim() | |
.split("\n") | |
.map(Number) | |
const sums = | |
numbers | |
.flatMap(n => |
The idea of this document is to imagine an implementation of a browser plugin for elm-ui, similar to Vue devtools or React Developer Tools.
These developer tools add new panels to the browser's devtools whenever Vue or React components are detected.
It is not fully specified what exactly an elm-ui "devtool panel" could be able to do. The bare minimum requirement is to visualize the "element tree" similar to the way the Inspector panel lets you visualize the DOM tree.
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
/* Implementing a Maybe type to learn about typescript. | |
Maybe API: https://package.elm-lang.org/packages/elm/core/latest/Maybe | |
The first approach is just trying to copy the exact same functions you'd have in a functional language: | |
*/ | |
type Maybe<T> = | |
| { tag: 'Just'; value: T } | |
| { tag: 'Nothing' } |
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
function $(x, y) { | |
return y ? x.querySelector(y) : document.querySelector(x); | |
} | |
function $$(x, y) { | |
return Array.from(y ? x.querySelectorAll(y) : document.querySelectorAll(x)); | |
} | |
/* Usage: | |
const div = $("div"); |
NewerOlder