This file contains hidden or 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
import ASQ from 'asynquence'; | |
import "asynquence-contrib" | |
import fetch from 'isomorphic-unfetch'; | |
var fetcher = (url) => | |
ASQ(url) | |
.then((done) => | |
fetch(url) | |
.then(res => res.json()) | |
.then((data) => done(data)) |
This file contains hidden or 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
function getGradedSumInsured (data) { | |
return data.reduce((result, member) => { | |
if (member["Relationship"] === "self") { | |
var si = member["Sum Insured"] | |
if (result[si]) { | |
result[si].push(member["Email"]) | |
} else { | |
result[si] = [member["Email"]] | |
} | |
} |
This file contains hidden or 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
// https://stackoverflow.com/a/18197341/1481710 | |
function download(filename, text) { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); |
This file contains hidden or 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
// thanks 🙏 | |
// https://github.com/jquense/yup/issues/97 | |
function equalTo(ref, msg) { | |
return this.test({ | |
name: 'equalTo', | |
exclusive: false, | |
message: msg || '${path} must be the same as ${reference}', | |
params: { | |
reference: ref.path |
This file contains hidden or 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
// this is a tagged template function | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates | |
// Example | |
// pluralize`You have ${events.length} ${["meeting","meetings"]} today` | |
export default function pluralize( | |
strings, | |
num, | |
[singularWord, pluralWord] = [] | |
) { | |
let word, emptyWord; |
This file contains hidden or 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
function add1(v) { return v + 1}; | |
function isOdd(v) {return v % 2 === 1}; | |
function sum (total, v) {return total + v}; | |
var list = [2, 5, 8, 11, 14, 17, 20]; | |
list | |
.map(add1) | |
.filter(isOdd) | |
.reduce(sum) |
This file contains hidden or 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 shouldShowError = () => { | |
var { touched, errors } = form; | |
return Object.entries(touched).some( | |
([key, value]) => value && errors[key] | |
); | |
}; |
This file contains hidden or 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
var trampoline = (fn) => | |
(...args) => { | |
var result = fn(...args); | |
while (typeof result === "function") { | |
result = result() | |
} | |
return result | |
} |
This file contains hidden or 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
function Observable(forEach) { | |
this._forEach = forEach; | |
} | |
Observable.prototype = { | |
forEach: function(onNext, onError, onCompleted) { | |
if (typeof onNext === "function") { | |
this._forEach({ | |
onNext: onNext, | |
onError: onError || function() {}, |
This file contains hidden or 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
export const USER_JOB_ROLES = new Map([ | |
[ | |
"Software Engineer", | |
[ | |
"Mobile Developer", | |
"Frontend Developer", | |
"Backend Developer", | |
"Full-Stack Developer", | |
"Engineering Manager", | |
"QA Engineer", |
NewerOlder