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 createFilterers() { | |
const _filters = { | |
ids: [], | |
fns: {}, | |
} | |
return { | |
addFilter(name, fn) { | |
_filters.ids.push(name) | |
_filters.fns[name] = fn |
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 React, { isValidElement } from 'react' | |
import isString from 'lodash/isString' | |
import isFunction from 'lodash/isFunction' | |
import { GoCheck, GoAlert } from 'react-icons/go' | |
import { FaInfoCircle } from 'react-icons/fa' | |
import { MdPriorityHigh } from 'react-icons/md' | |
import { toast } from 'react-toastify' | |
/* | |
Calling these toasts most likely happens in the UI 100% of the time. |
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 { toast } from 'react-toastify' | |
import { | |
info as toastInfo, | |
success as toastSuccess, | |
toastIds, | |
} from 'util/toast' | |
const onOnline = () => { | |
if (toast.isActive(toastIds.internetOffline)) { | |
toast.dismiss(toastIds.internetOffline) |
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 React from 'react' | |
import { GoCheck, GoAlert } from 'react-icons/go' | |
import { FaInfoCircle } from 'react-icons/fa' | |
import { MdPriorityHigh } from 'react-icons/md' | |
import { toast } from 'react-toastify' | |
/* | |
Calling these toasts most likely happens in the UI 100% of the time. | |
So it is safe to render components/elements as toasts. | |
*/ |
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 utilizePrefixer(prefix) { | |
return function(word) { | |
return `${prefix}${word}` | |
} | |
} | |
const withMoneySign = utilizePrefixer('$') | |
const withCompanyName = utilizePrefixer('Fandango') | |
const tenDollars = withMoneySign('9.99') | |
const formHeader = withCompanyName( |
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 prefixWordWithUnderscore(word) { | |
return `_${word}` | |
} | |
const words = ['coffee', 'apple', 'orange', 'phone', 'starbucks'] | |
const prefixedWords = words.map(prefixWordWithUnderscore) | |
// result: ["_coffee", "_apple", "_orange", "_phone", "_starbucks"] |
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 createSpecies(type, name, gender) { | |
if (type === 'frog') { | |
return createFrog(name, gender) | |
} else if (type === 'human') { | |
return createHuman(name, gender) | |
} else if (type == undefined) { | |
throw new Error('Cannot create a species with an unknown type') | |
} | |
} |
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 Frog(name, gender) { | |
this.name = name | |
this.gender = gender | |
this.leap = function(feet) { | |
console.log(`Leaping ${feet}ft into the air`) | |
} | |
} |
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 Frog(name, gender) { | |
this.name = name | |
this.gender = gender | |
} | |
Frog.prototype.leap = function(feet) { | |
console.log(`Leaping ${feet}ft into the air`) | |
} |
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 createFrog(name) { | |
const children = [] | |
return { | |
addChild(frog) { | |
children.push(frog) | |
}, | |
} | |
} |