Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Adding type safety to object IDs in TypeScript. Parent comment
function is<T extends string>(value: string, prefix: T): value is `${typeof prefix}_${string}` { return value.startsWith(`${prefix}_`) }
If you do that often you probably want to create separate functions, e.g.:
function isFactory<T extends string>(prefix: T) { return (value: string) => is(value, prefix) } const isUser = isFactory('user') const isOrder = isFactory('order')
There are no comments on this comment yet.
If you do that often you probably want to create separate functions, e.g.:
Not too bad.