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
| type DeepReadonly<T> = | |
| T extends [infer A] ? DeepReadonlyObject<[A]> : | |
| T extends [infer A, infer B] ? DeepReadonlyObject<[A, B]> : | |
| T extends [infer A, infer B, infer C] ? DeepReadonlyObject<[A, B, C]> : | |
| T extends [infer A, infer B, infer C, infer D] ? DeepReadonlyObject<[A, B, C, D]> : | |
| T extends [infer A, infer B, infer C, infer D, infer E] ? DeepReadonlyObject<[A, B, C, D, E]> : | |
| T extends [infer A, infer B, infer C, infer D, infer E, infer F] ? DeepReadonlyObject<[A, B, C, D, E, F]> : | |
| T extends [infer A, infer B, infer C, infer D, infer E, infer F, infer G] ? DeepReadonlyObject<[A, B, C, D, E, F, G]> : | |
| T extends (infer A)[] ? DeepReadonlyArray<A> : | |
| T extends Function ? T : // can change to never to forbid functions |
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
| // Licensed under CC BY 4.0. | |
| type $If<X: boolean, Then, Else = empty> = $Call< | |
| & ((true, Then, Else) => Then) | |
| & ((false, Then, Else) => Else), | |
| X, | |
| Then, | |
| Else, | |
| >; |
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
| const regexp = (xs, ...ys) => (xs2, ...ys2) => | |
| new RegExp( | |
| String.raw(xs, ...ys).replace( | |
| // Find additional escape sequences, | |
| // spaces, line breaks, comments: | |
| /\\[#\n ]|#.*$|[\n ]/gm, | |
| // Remove spaces, line breaks, comments, | |
| // unescape additional sequences: | |
| x => (x[0] === '\\' ? x[1] : ''), | |
| ), |
NewerOlder