Even though as a society the shift is likely too expensive and hard to make happen, that doesn't make it less true.
10 is divisible by 2 and 5
Remember how easy it was to learn your 2 and 5 times tables? Just a nice repeating pattern.
function product<K extends string, T>(arrays: Record<K, T[]>): Record<K, T>[] { | |
return Object.entries(arrays).reduce( | |
// @ts-expect-error Object.entries is resolving K to string | |
(acc, [field, arr]: [K, T[]]): Record<K, T>[] => | |
arr.flatMap((value) => | |
acc.map((existing) => ({ ...existing, [field]: value })), | |
), | |
[{}] as Record<K, T>[], | |
) as Record<K, T>[]; | |
} |
<html> | |
<head> | |
<style> | |
body { | |
background-color: hsl(220deg, 13%, 19%); | |
color: white; | |
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, | |
Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", | |
"Segoe UI Symbol"; | |
display: flex; |
/** | |
* Conditionally require additional data for function calls based on first parameter | |
* Allows a union of possible interfaces that describe a minimum amount of data required | |
* Values not named may still be used and have no minimum amount of data | |
* | |
* Extending on the work by David Sheldrick in https://artsy.github.io/blog/2018/11/21/conditional-types-in-typescript/ | |
*/ | |
interface BaseShape { | |
name: string; |
Even though as a society the shift is likely too expensive and hard to make happen, that doesn't make it less true.
10 is divisible by 2 and 5
Remember how easy it was to learn your 2 and 5 times tables? Just a nice repeating pattern.
/** | |
* A TypeScript example of a generic type used | |
* by a function where the type passed | |
* into the function allows TypeScript to infer the | |
* type of another value passed in. | |
*/ | |
interface Params<I> { | |
items: I[]; | |
render: (item: I) => void; |
/** | |
* An example redux reducer file | |
* To be imported into a centralized file, typically using combineReducers. | |
* | |
* This pattern focuses on type safety with minimal re-declaring of types. | |
* | |
* Format of a file: | |
* - Actions Types | |
* - Actions | |
* - State |
/** | |
* Demonstrates the different between Webpack v4 and Webpack v5 toJson behaviour | |
**/ | |
const webpack = require("webpack"); | |
const compiler = webpack({}); | |
compiler.run((err, res) => { | |
if (err) { |
class A extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
B: undefined | |
}; | |
import('./B').then(bModule => { | |
this.setState({ B: bModule.default }); | |
}); | |
} |
<style> | |
body { | |
padding: 0; | |
margin: 0; | |
background-color: hsl(0, 0%, 5%); | |
color: hsl(0, 0%, 95%); | |
} | |
</style> | |
<h1>Game on</h1> | |
<div id="players"></div> |
// eslint -f json . > output.json | |
const data = require('./output.json'); | |
const result = {}; | |
const files = new Set(); | |
data | |
.filter(({ warningCount, errorCount }) => warningCount > 0 || errorCount > 0) | |
.forEach(fileProps => { | |
const { messages, filePath } = fileProps; |