Skip to content

Instantly share code, notes, and snippets.

View Caballerog's full-sized avatar
:octocat:
live$.pipe(map(person => person.teach(me)),tap(me => me.betterEachDay())))

Carlos Caballero Caballerog

:octocat:
live$.pipe(map(person => person.teach(me)),tap(me => me.betterEachDay())))
View GitHub Profile
/** Operators */
const map = (mapper) => (reducer) => (acc, val) => reducer(acc, mapper(val));
const filter = (predicate) => (reducer) => (acc, val) =>
predicate(val) ? reducer(acc, val) : acc;
const some = (predicate) => (_) => (acc, val) =>
acc !== true ? predicate(val) : true;
/** */
@gquittet
gquittet / recursive_optimization.js
Last active April 13, 2020 03:33
Tail Call Optimization (TCO) and Trampoline optimization for recursive function
const startDate = new Date('2020-02-29 11:42:00')
const endDate = new Date('2020-03-02 17:49:23')
// Default Recursion
// const map = (fn, [head, ...tail]) => {
// if (!head && tail.length === 0) {
// return []
// }
// return [fn(head), ...map(fn, tail)]
// }
@EtienneR
EtienneR / user.js
Created January 7, 2016 23:39
XMLHttpRequest RESTful (GET, POST, PUT, DELETE)
// Get all users
var url = "http://localhost:8080/api/v1/users";
var xhr = new XMLHttpRequest()
xhr.open('GET', url, true)
xhr.onload = function () {
var users = JSON.parse(xhr.responseText);
if (xhr.readyState == 4 && xhr.status == "200") {
console.table(users);
} else {
console.error(users);