MCPcopy Create free account
hub / github.com/brillout/react-streaming / assert

Function assert

src/utils/assert.ts:29–54  ·  view source on GitHub ↗
(condition: unknown, debugInfo?: unknown)

Source from the content-addressed store, hash-verified

27assertSingleVersion()
28
29function assert(condition: unknown, debugInfo?: unknown): asserts condition {
30 if (condition) {
31 return
32 }
33
34 const debugStr = (() => {
35 if (!debugInfo) {
36 return ''
37 }
38 const debugInfoSerialized = typeof debugInfo === 'string' ? debugInfo : '`' + JSON.stringify(debugInfo) + '`'
39 return `Debug info (this is for the ${projectInfo.projectName} maintainers; you can ignore this): ${debugInfoSerialized}.`
40 })()
41
42 const internalError = createErrorWithCleanStackTrace(
43 [
44 `${internalErrorPrefix} You stumbled upon a bug in ${projectInfo.projectName}'s source code.`,
45 `Reach out at ${projectInfo.githubRepository}/issues/new and include this error stack (the error stack is usually enough to fix the problem).`,
46 'A maintainer will fix the bug (usually under 24 hours).',
47 `Do not hesitate to reach out as it makes ${projectInfo.projectName} more robust.`,
48 debugStr,
49 ].join(' '),
50 numberOfStackTraceLinesToRemove,
51 )
52
53 throw internalError
54}
55
56function assertUsage(condition: unknown, errorMessage: string): asserts condition {
57 if (condition) {

Callers 15

getInitDataFunction · 0.85
assertIsNotBrowserFunction · 0.85
assertPosixPathFunction · 0.85
assertVersionFunction · 0.85
parseVersionFunction · 0.85
debug.tsFile · 0.85
chunkFunction · 0.85
useSuspenseFunction · 0.85
getSuspenseIdFunction · 0.85
renderToStreamFunction · 0.85
assertReactFunction · 0.85
useAsyncFunction · 0.85

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…