Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/editTelemetry/browser/randomService.ts
4782 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { generateUuid } from '../../../../base/common/uuid.js';
7
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
8
9
export const IRandomService = createDecorator<IRandomService>('randomService');
10
11
export interface IRandomService {
12
readonly _serviceBrand: undefined;
13
14
generateUuid(): string;
15
generatePrefixedUuid(prefix: string): string;
16
}
17
18
export class RandomService implements IRandomService {
19
readonly _serviceBrand: undefined;
20
21
generateUuid(): string {
22
return generateUuid();
23
}
24
25
/** Namespace should be 3 letter. */
26
generatePrefixedUuid(namespace: string): string {
27
return `${namespace}-${this.generateUuid()}`;
28
}
29
}
30
31