MCPcopy
hub / github.com/angular/angular / assertPlatform

Function assertPlatform

packages/core/src/platform/platform.ts:117–134  ·  view source on GitHub ↗
(requiredToken: any)

Source from the content-addressed store, hash-verified

115 * @publicApi
116 */
117export function assertPlatform(requiredToken: any): PlatformRef {
118 const platform = getPlatform();
119 if (!platform) {
120 throw new RuntimeError(RuntimeErrorCode.PLATFORM_NOT_FOUND, ngDevMode && 'No platform exists!');
121 }
122
123 if (
124 (typeof ngDevMode === 'undefined' || ngDevMode) &&
125 !platform.injector.get(requiredToken, null)
126 ) {
127 throw new RuntimeError(
128 RuntimeErrorCode.MULTIPLE_PLATFORMS,
129 'A platform with a different configuration has been created. Please destroy it first.',
130 );
131 }
132
133 return platform;
134}
135
136/**
137 * Returns the current platform in the browser environment. In the server environment,

Callers 1

createPlatformFactoryFunction · 0.85

Calls 2

getPlatformFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…