- Heavy library but not needed initially (threejs)
- Temporal components (that come and go or are conditionally loaded): tooltips, model, notification, dialog, page scrolling
- Routes
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
// Prop Collections and Getters | |
// merge all passed functions into one | |
const mergeFn = | |
(...fns) => | |
(...args) => | |
fns.forEach(fn => fn?.(...args)) | |
function useToggle() { | |
const [on, setOn] = React.useState(false) |
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
// Control Props | |
import * as React from 'react' | |
import warning from 'warning' | |
import {Switch} from '../switch' | |
const mergeAll = | |
(...fns) => | |
(...args) => | |
fns.forEach(fn => fn?.(...args)) |
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
function getFirstItem<Type>(list: Type[]): Type { | |
return list[0] | |
} | |
const item = getFirstItem([1]) | |
const item2 = getFirstItem(['']) | |
const item3 = getFirstItem([new Object()]) | |
type Tree<Type> = { | |
value: Type |
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
interface Fruit { | |
readonly name?: string | |
readonly color?: string | |
readonly sweetness?: number | |
} | |
type Properties<Type> = keyof Type | |
type Values<Type> = Type[Properties<Type>] | |
type FruitProperties = Properties<Fruit> |
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
type AppleLiteral = 'Apple' | |
let appleName: AppleLiteral = 'Apple' | |
type LiteralIsStringType<Type> = Type extends string | |
? string | |
: Type extends number | |
? number | |
: Type extends boolean | |
? boolean |
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
// Context Module Functions | |
import * as React from 'react' | |
import {dequal} from 'dequal' | |
import * as userClient from '../user-client' | |
import {useAuth} from '../auth-context' | |
const UserContext = React.createContext() | |
UserContext.displayName = 'UserContext' |
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
class OrderManager { | |
orders = new Set() | |
execute(command, ...args) { | |
return command.run(this.orders, ...args) | |
} | |
} | |
class Command { | |
constructor(steps) { |
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 states = { | |
PENDING: 'PENDING', | |
FULFILLED: 'FULFILLED', | |
REJECTED: 'REJECTED', | |
} | |
const isThenable = (thing) => thing && typeof thing.then === 'function' | |
class MyPromise { | |
_state = states.PENDING |
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
/******/ function __webpack_require__(moduleId) { | |
/******/ // Check if module is in cache | |
/******/ var cachedModule = __webpack_module_cache__[moduleId] | |
/******/ if (cachedModule !== undefined) { | |
/******/ return cachedModule.exports | |
/******/ | |
} | |
/******/ // Create a new module (and put it into the cache) | |
/******/ var module = (__webpack_module_cache__[moduleId] = { | |
/******/ // no module.id needed |