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 dificuldadeCasas = [ | |
50, | |
55, | |
60, | |
70, | |
75, | |
80, | |
85, | |
90, | |
95, |
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 liga(x,y){ | |
x.proximos.push(y) | |
y.proximos.push(x) | |
} | |
function geraNo(id, tamanho){ | |
return { | |
id, | |
tamanho, | |
caminho: '', |
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 hadChanged = list => obj => Object.keys(list) | |
.filter(k => obj[k] !== list[k]) | |
.reduce((a, b) => { | |
list[b] = obj[b] | |
return a || !!b | |
}, false) | |
export default hadChanged | |
/* | |
var list = { a: 'a', b: '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
const cavaleiro = [1.5, 1.4, 1.3, 1.2, 1.1] | |
const casas = [ | |
[cavaleiro[0]], | |
[cavaleiro[1]], | |
[cavaleiro[2]], | |
[cavaleiro[3]], | |
[cavaleiro[4]], | |
[cavaleiro[0]], | |
[cavaleiro[1]], | |
[cavaleiro[2]], |
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 proto = Object.create(Array.prototype) | |
Object.defineProperty(proto, 'sew', { | |
value: function sew (a) { | |
(a || a === 0) && this.push(a) | |
return this | |
} | |
}) | |
function extendArray (a) { |
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
funtion download (obj) { | |
const a = document.createElement('a') | |
document.body.appendChild(a) | |
a.style = 'display: none' | |
const str = JSON.stringify(obj, null, 4) | |
const blob = new window.Blob([str], {type: 'application/json'}) | |
const url = window.URL.createObjectURL(blob) | |
a.href = url | |
a.download = 'obj.json' |
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 serial(obj, i, farr) { | |
if (i === farr.length) { | |
console.log(obj) | |
} else { | |
farr[i](obj, e => { | |
serial(e, i + 1, farr) | |
}) | |
} | |
} |
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
async function* asyncAnimationFrame () { | |
const h = {} | |
h.promise = new Promise(r => h.resolve = r) | |
h.flipFrame = () => { | |
h.resolve() | |
h.promise = new Promise(r => h.resolve = r) | |
} | |
try { | |
while (true) { | |
h.idAF = requestAnimationFrame(h.flipFrame) |
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
/* | |
https://www.youtube.com/watch?v=k7-N8R0-KY4&list=PL0zVEGEvSaeEd9hlmCXrk5yUyqUag-n84 | |
@Gegeg | |
Could you do this with reduce? | |
*/ | |
const categories = [ | |
{ id: 'a', parent: '0'}, | |
{ id: 'b', parent: '0'}, | |
{ id: 'c', parent: 'a'}, |
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 reduce = iterable => function* reducerable (fn, s0) { | |
let acc = s0 | |
for (const i of iterable) { | |
yield acc = fn(i, acc) | |
} | |
} | |
export default reduce |
OlderNewer