Tech lead @ La Creativería
glixius @ GitHub
glopezr@lacreativeria.com
+506 8703 1266
fs.readdir(source, function (err, files) {
if (err) {
console.log('Error finding files: ' + err)
} else {
files.forEach(function (filename, fileIndex) {
console.log(filename)
gm(source + filename).size(function (err, values) {
if (err) {
console.log('Error identifying file size: ' + err)
} else {
console.log(filename + ' : ' + values)
aspect = (values.width / values.height)
widths.forEach(function (width, widthIndex) {
height = Math.round(width / aspect)
console.log('resizing ' + filename + 'to ' + height + 'x' + height)
this.resize(width, height).write(dest + 'w' + width + '_' + filename, function(err) {
if (err) console.log('Error writing file: ' + err)
})
}.bind(this))
}
})
})
}
})🧔🏽
👨🏻🍳
🥘
Gilberto
Rémulo
Arroz de maíz
📲
MDN
A Promise is an object representing the eventual completion or failure of an asynchronous operation.
Gilberto
Delivery ticket.
👦🏻
👩🏽
🍗
Kevin
Cajera
Pollo frito
📟
Dispositivo
Pending
⏳
Fulfilled
👌🏽
Rejected
👎🏽
Settled
😌
Simple
then
catch
finally
Complex
all
race
Create
resolve
reject
1
2
3
Chaining
Error propagation
Nesting
Keep your promises and