MCPcopy Create free account
hub / github.com/angular/angular / assertPlatform

Function assertPlatform

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

Source from the content-addressed store, hash-verified

108 * @publicApi
109 */
110export function assertPlatform(requiredToken: any): PlatformRef {
111 const platform = getPlatform();
112 if (!platform) {
113 throw new RuntimeError(RuntimeErrorCode.PLATFORM_NOT_FOUND, ngDevMode && 'No platform exists!');
114 }
115
116 if (
117 (typeof ngDevMode === 'undefined' || ngDevMode) &&
118 !platform.injector.get(requiredToken, null)
119 ) {
120 throw new RuntimeError(
121 RuntimeErrorCode.MULTIPLE_PLATFORMS,
122 'A platform with a different configuration has been created. Please destroy it first.',
123 );
124 }
125
126 return platform;
127}
128
129/**
130 * 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