This file contains hidden or 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 GoogleChart exposing (..) | |
import Html exposing (Html) | |
import Html.Attributes as HtmlA | |
import Json.Encode as E | |
import List.Extra as List | |
import Chart exposing (..) | |
colors = |
This file contains hidden or 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
Show hidden characters
{ | |
"presets": [ | |
"@babel/preset-react", | |
[ | |
"@babel/preset-env", | |
{ | |
"targets": { | |
"browsers": [ | |
"last 2 versions", | |
"ie >= 11" |
This file contains hidden or 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 sum(a, b) { | |
// Aquí puede haber comentarios importantes... | |
// ...sobre todo para gente que hace librerías, etc... | |
return a + b; | |
} | |
// En la primera versión de la especificación... | |
sum.toString() // > "function sum() { return a + b }" |
This file contains hidden or 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
Symbol('react').description // > "react" | |
Symbol.iterator.description // > "Symbol.iterator" | |
Symbol.for('preact').description // > "preact" |
This file contains hidden or 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
try { | |
// hacer algo útil... | |
} catch (err) { | |
// utilizar el parámetro `err` para algo... | |
} | |
try { | |
// ...más cosas útiles... | |
} catch { | |
// ...gestionar el error sin el parámetro! |
This file contains hidden or 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, como ejemplo, que queremos elevar al cubo (^3) las habilidades de Eren | |
const eren = { strength: 50, health: 100, height: 170 } | |
// Utilizamos nuestro ya conocido método `Object.entries` | |
// para pasar del dominio de los objetos al de los arrays... | |
const aux = Object.entries(eren) | |
// > [["strength", 50], ["health", 100], ["height", 170]] | |
// Ahora que estamos en el dominio de los arrays, podemos hacer un simple `map`! | |
const array = aux.map(([key, value]) => [key, value ** 3]) |
This file contains hidden or 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 text = " Levy " | |
text.trim() // > "Levy" | |
text.trimStart() // > "Levy " | |
text.trimEnd() // > " Levy" |
This file contains hidden or 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 array = [1, 3] | |
const f = x => [x, x + 1] | |
array.map(f) // > [[1, 2], [3, 4]] | |
array.flatMap(f) // > [1, 2, 3, 4] | |
// Ahora un ejemplo un poco más curioso... | |
const heroes = ["Eren Jaeger", "Mikasa Ackerman"] | |
const splitBySpace = xs => xs.split(" ") |
This file contains hidden or 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 arr = [1, 2, 3, [4, 5]] | |
arr.flat() // > [1, 2, 3, 4, 5] | |
const arr1 = [1, 2, [3, 4, [5, 6]]] | |
arr1.flat(2) // > [1, 2, 3, 4, 5, 6] | |
const arr2 = [1, 2, [3, 4, [5, 6, [7, 8, [9, 10]]]]] | |
arr2.flat(Infinity) // > [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
// Si tienes huecos vacíos en tu array también los limpiará! |
This file contains hidden or 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
git ls-files | grep \\.js$ | xargs wc -l |