JS, Node.js, Frontend, Backend, Firebase, Express, Patrones, HTML5_APIs, Asincronía, Websockets, Testing
Node.js es un entorno en tiempo de ejecución multiplataforma, de código abierto, para la capa del servidor (pero no limitándose a ello) basado en el lenguaje de programación ECMAScript, asíncrono, con I/O de datos en una arquitectura orientada a eventos y basado en el motor V8 de Google. Fue creado con el enfoque de ser útil en la creación de programas de red altamente escalables, como por ejemplo, servidores web. Fue creado por Ryan Dahl en 2009 y su evolución está apadrinada por la empresa Joyent, que además tiene contratado a Dahl en plantilla - Wikipedia
Otra manera es posible
Puntos Fuertes
- Asincronía (no bloqueo)
- Backend completo
- NPM (comunidad)
- Single thread (paralelismo)
- Librerías propias
- Utilidades
- Código abierto
- Basado en el V8 (escrito en C++) de Google
- Multiplataforma
- Orientado a Eventos
- No se limita solo a servidores HTTP
Librerías interesantes
- awesome Node.js
- Grunt
- Gulp
- Express
- Mongoose
- Socket.io
- Apache Cordova
- Async
- Chalk
- J5
- GraphicsMagick
- Marked
- Node-restify
- Webpack
- Morgan
- Nodemailer
- Passportjs
- Cheerio
- X-ray
- Bower
- PM2
- Electron
- Yeoman
- Babel
- Helmet
- Faker
- Protractor
- Nightwatch.js
- Cypress.io
IO.js
io.js has merged with the Node.js project again. There won't be any further io.js releases. All of the features in io.js are available in Node.js v4 and above.
Dependencias, dependencias, dependencias... y más dependencias
module.exports = leftpad;
function leftpad (str, len, ch) {
str = String(str);
var i = -1;
if (!ch && ch !== 0) ch = ' ';
len = len - str.length;
while (++i < len) {
str = ch + str;
}
return str;
}
- How one developer just broke Node, Babel and thousands of projects in 11 lines of JavaScript
- A discussion about the breaking of the Internet
- I’ve Just Liberated My Modules
- Left-pad en GitHub
- Is left-pad Indicative of a Fragile JavaScript Ecosystem?
- Overcoming JavaScript Fatigue
- One developer just broke Node, Babel and thousands of projects in 11 lines of JavaScript
- How 17 Lines of Code Took Down Silicon Valley’s Hottest Startups
- Npm package author revokes his packages, breaking tons of builds
- ¿Y si el software Open Source desapareciera?
- El programador que borró 11 líneas de código y se cargó Internet
EventStream is like functional programming meets IO
var es = require('event-stream')
var inspect = require('util').inspect
process.stdin //connect streams together with `pipe`
.pipe(es.split()) //split stream to break on newlines
.pipe(es.map(function (data, cb) { //turn this async function into a stream
cb(null
, inspect(JSON.parse(data))) //render it nicely
}))
.pipe(process.stdout) // pipe it to stdout !
- EventStream | NPM
- dominictarr/event-stream | issue:I don't know what to say
- Synk | Malicious code found in npm package event-stream downloaded 8 million times in the past 2.5 months
- Reddit | "I don't know what to say."– Backdoor in popular event-stream NPM repo (github.com)
- Widely used open source software contained bitcoin-stealing backdoor
- Malicious code in npm ‘event-stream’ package targets a bitcoin wallet and causes 8 million downloads in two months
- event-stream vulnerability explained
- Check your repos... Crypto-coin-stealing code sneaks into fairly popular NPM lib (2m downloads per week)
Características estrella
- Code together in real time
- Share your IDE, your workspace, a preview, or your running app
- Replay all edits and see your code at any point in time
Otras características
- Preview in any browser
- Built-In Terminal
- Language Tools
- Debugger
- Split View
- Themes
- Run Panel
- Key Bindings Editor
- VIM/Emacs/Sublime Mode
- Built-In Image Editor
Más
-
Versiones:
- Pares -> Estables
- Impares -> inestables
-
Versiones LTS:
-
Grandes Cambios:
-
Comprobar version:
- Node
node -v
- Npm
npm -v
- Hola mundo!:
console.log("Hola Mundo!");
- Hola mundo! (retraso):
setTimeout(function() {
console.log("Hola Futuro...!");
}, 5000);
- Hola mundo! (repetición):
setInterval(function() {
console.log("Hola Futuro...!");
}, 1000);
console.assert(value[, message][, ...])
console.assert(true, 'No me muestro!');
console.assert(false, 'Me muestro');
console.time() y console.timeEnd()
console.time('100-elementos');
for (var i = 0; i < 100; i++) {
console.log(i);
}
console.timeEnd('100-elementos');
// 100-elementos: 5ms
Sustituciones
- %d Enteros y coma flotante
console.log("Tenemos %d usuarios conectados", 10);
- %s Cadenas
console.log("Tenemos %s usuarios conectados", "muchos");
- %j Objetos JSON
console.log("Tenemos %j", {alumnos:{total:15, estado:"conectados"}});
Loop
Arquitecura diferente