Existem 3 entradas possiveis
true
false
undefined
as saídas serão:
undefinded
=>true
export default Vue => { | |
Vue.mixin({ | |
created () { | |
const { title } = this.$options | |
if (title !== undefined) { | |
this.$title = title | |
} | |
} | |
}) |
import { identity } from 'lodash' | |
import waith from './waith' | |
export default (action, repetitions, timeToWaith = 3000) => { | |
const onError = counter => () => { | |
if (counter < repetitions) { | |
return run(counter + 1) | |
} | |
return Promise.reject(new Error('TRIES_FAILURE')) |
Em JavaScript há uma comportamento chamado hoisting
.
O uso de var
trazia algumas pegadinhas, como por exemplo, declarar a mesma variavel 2x usando var
var abc = 25
// ...
// ...
var abc = 99
(Descrição completa e mais comandos aqui - https://npmjs.org/doc/index.html)
npm install <module-name> --save
# Versions | |
# Where the ambientum cache will live | |
A_CACHE_HOME=$HOME/.cache/ambientum | |
# Define specific cache directories | |
A_NPM_CONFIG=$A_CACHE_HOME/npm-config | |
A_NPM_CACHE=$A_CACHE_HOME/npm-cache | |
A_COMPOSER_CACHE=$A_CACHE_HOME/composer |
#["LÓGICA DE PROGRAMAÇÃO" É BOBAGEM, e explicarei porquê.]
Se preparem que o texto é longo.
Várias vezes chegam novatos aqui perguntando como começar, e a galera diz "estuda lógica primeiro, depois vai pra linguagem X". Vivo dizendo que é bobagem. Ontem, em particular, falei isso, e vieram várias pessoas por inbox me perguntar porquê (e uma pra me xingar, achando que falei por arrogância).
Pra facilitar, eu vou escrever uma boa explicação de porquê "lógica de programação" é furada, doa a quem doer, e postar na APDA e no fórum da EnergyLabs (para futuras referências, porque esse assunto vai voltar, ctz).
/** Async version of Array.prototype.reduce() | |
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => { | |
* acc[v] = await (await fetch(v)).json(); | |
* return acc; | |
* }, {}); | |
*/ | |
export async function reduce(arr, fn, val, pure) { | |
for (let i=0; i<arr.length; i++) { | |
let v = await fn(val, arr[i], i, arr); | |
if (pure!==false) val = v; |