Skip to content

Instantly share code, notes, and snippets.

Avatar
🎖️
Let's help each other!

Vitalii Dasaev vitaliidasaev

🎖️
Let's help each other!
View GitHub Profile
@emptyother
emptyother / Guid.ts
Created December 7, 2017 20:24
GUID class for Typescript
View Guid.ts
class Guid {
public static newGuid(): Guid {
return new Guid('xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random() * 16 | 0;
const v = (c == 'x') ? r : (r & 0x3 | 0x8);
return v.toString(16);
}));
}
public static get empty(): string {
return '00000000-0000-0000-0000-000000000000';