Skip to content

Instantly share code, notes, and snippets.

View arturitu's full-sized avatar

Arturo Paracuellos arturitu

View GitHub Profile
async function getTodosList() {
const response = await fetch('https://jsonplaceholder.typicode.com/todos'); //fetch es await function. Podemos llamarlo con await y esperará aquí
const data = await response.json(); //.json es método async, podemos llamarlo con await y esperará aquí.
return data; //el return lo hará cuando la línea anterior acabe, después de esperar la conversión a json de la response
}
async function countCompletedTodosTitleLength(){
const todos = await getTodosList(); //Llamamos a getTodosList y esperamos aquí hasta que acabe.
console.log(todos
@cvan
cvan / events.js
Created October 3, 2014 07:38
happy times with events using EventEmitter with browserify/node
var Emitter = require('events').EventEmitter;
function E(emitter, options) {
this.emitter = emitter;
this.options = options;
}
E.create = function (options) {
var emitter = new Emitter();
@mflux
mflux / gist:86dac07cdc6a16baafe1
Created July 23, 2014 23:20
A small hacky module for THREE.js that forces a mesh and its texture to be uploaded into the GPU regardless of it's seen on-screen or not, preventing lag when the object comes into view.
ForceGPULoad = (function(){
var renderer;
var scene;
var camera;
return {
buffer: function( object3D ){
// push
var originalPosition = object3D.position.clone();
object3D.position.set( 0,0,0 );