This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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; | |
/** */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |