const identity = x => x
const withIndex = fn => (_, i) => fn(i);
const getIndex = withIndex(identity);
const positiveIntegers = (length) => Array.from({ length }).map(getIndex);
const isEven = n => n % 2 === 0;
const isOdd = n => !isEven(n);
const odd = (...numbers) => numbers.filter(isOdd);
const reciprocal = n => 1 / n;
const inverse = (...numbers) => numbers.map(reciprocal);| function searchParamsToObject(params: URLSearchParams) { | |
| const uniqueKeys = [...new Set(params.keys())]; | |
| return Object.fromEntries(uniqueKeys.map(key => [ | |
| key, | |
| params.getAll(key).length > 1 ? params.getAll(key) : params.get(key), | |
| ])); | |
| } |
| interface TypedResponse<TJson> extends globalThis.Response { | |
| json: () => Promise<TJson>; | |
| } | |
| async function typedFetch<T>(...args: Parameters<typeof fetch>) { | |
| const response = await fetch(...args); | |
| if (!response.ok) throw response; | |
| return response as TypedResponse<T>; | |
| } |
| defaults write com.apple.screencapture location ~/Screenshots/ |
| class IndexedObjectArray extends Array { | |
| #map; | |
| constructor(length) { | |
| super(length); | |
| } | |
| toMap() { | |
| return this.#map; | |
| } |
| function squares(n: number) { | |
| return (n * (n + 1) * (2 * n + 1)) / 6; | |
| } |
Curated by Joe Maffei
This document outlines key considerations for determining when a feature can be considered "done." It's crucial to address these points as early as possible in the development process and continue to revisit them at each stage. By doing so, we can ensure higher quality, reduce rework, and streamline our development pipeline. Consider these points at the following stages:
- When drafting requirements documents
- During the design and wireframing phase
- While writing user stories or bug tickets
- Throughout the development process
| /** | |
| * Converts an iterable to an object, keeping only key/value pairs that are both strings. | |
| */ | |
| function pickStringKeysAndValues< | |
| T extends { entries(): IterableIterator<[unknown, unknown]> }, | |
| >(iterable: T): Record<string, string> { | |
| let result: Record<string, string> = {}; | |
| for (let [key, value] of iterable.entries()) { | |
| if (typeof key === 'string' && typeof value === 'string') { | |
| result[key] = value; |
| /** | |
| * Module-level variable where all of the global dependency injection | |
| * overrides are stored. | |
| */ | |
| const provisions = new Map<unknown, unknown>(); | |
| /** | |
| * Adds an override to the global dependency injection context. | |
| * TypeScript ensures that the signature of the override is the same | |
| * as that of the dependency being overridden. |
| function keyMirror<Obj>(...args: (keyof Obj)[]): Readonly<{ [Key in keyof Obj]: Key }> { | |
| let obj = {}; | |
| for (let arg of args) { | |
| Object.defineProperty(obj, arg, { | |
| configurable: false, | |
| enumerable: true, | |
| value: arg, | |
| writable: false, | |
| }); | |
| } |
NewerOlder