float rand(float n){return fract(sin(n) * 43758.5453123);}
float noise(float p){
float fl = floor(p);
float fc = fract(p);
return mix(rand(fl), rand(fl + 1.0), fc);
}
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
// Asuming both asyncProcess1 & asyncProcess2 takes 1 second each to proces | |
// .. Foo would take 2 seconds to execute | |
async function foo () { | |
const dep1 = await asyncProcess1() | |
const dep2 = await asyncProcess2() | |
console.log(dep1, dep2) | |
} | |
// .. Bar would take 1 second tu execute |
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 addPropToObj = key => obj => val => ({ ...obj, [key]: val }) | |
// Example | |
const firstObj = { a: 1, b: 2, c: 3 } | |
addPropToObj("d", firstObj, 4) // { a: 1, b: 2, c: 3, d: 4 } |
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 getPriorMonth = (date, range, goingBackwards = true) => { | |
if (range === 0) return date | |
let dateArr = date.split("-") | |
if (dateArr[1] === "01" && goingBackwards) return getPriorMonth(`${dateArr[0] - 1}-12`, range - 1) | |
else if (dateArr[1] === "12" && !goingBackwards) | |
return getPriorMonth(`${dateArr[0] + 1}-01`, range - 1) | |
else { | |
let month = goingBackwards ? Number(dateArr[1]) - 1 : Number(dateArr[1]) + 1 | |
if (month.toString().length === 1) month = `0${month}` |
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 concatCurryer = pre => cur => { | |
const preToConcat = Array.isArray(pre) ? pre : [pre] | |
const curToConcat = Array.isArray(cur) ? cur : [cur] | |
return [...preToConcat, ...curToConcat] | |
} | |
// Examples | |
const arr1 = [{ val: "a" }, { val: "b" }] | |
const arr2 = [{ val: "c" }, { val: "d" }] | |
const obj1 = { val: 1 } |