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
import { RSC_HEADER } from 'next/dist/client/components/app-router-headers'; | |
import { NextRequest } from 'next/server'; | |
// Next.js tries to prefetch react server components stuff automatically. | |
// It does that by sending requests with the `_rsc` search param flag and | |
// also setting the `rsc` header. | |
// For some reason, Next.js also does this for route handlers when you use | |
// server-side and client-side navigation to these route handlers. | |
// So basically you will see two request to the same route handler, one | |
// with _rsc parameter and another without. |
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 NullToUndefined<T> = { | |
[K in keyof T]: NullToUndefined<null extends T[K] ? Exclude<T[K], null> | undefined : T[K]>; | |
}; | |
type UndefinedToNull<T> = { | |
[K in keyof T]: UndefinedToNull<undefined extends T[K] ? Exclude<T[K], undefined> | null : T[K]>; | |
}; |
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
function leftJoin<A, B>(collection1: Array<A>, collection2: Array<B>, on: [keyof A, keyof B]): Array<A & Partial<B>> { | |
return collection1.map<A & Partial<B>>((leftObject) => { | |
const rightObject = collection2.find((item) => isEquals(leftObject, on[0], item, on[1])); | |
if (rightObject) { | |
return { ...leftObject, ...rightObject }; | |
} else { | |
return { ...leftObject }; | |
} | |
}); | |
} |