Created
April 30, 2015 20:55
-
-
Save jonocairns/fa258c1faadced9f86dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module app.common { | |
export class Guid { | |
public static newGuid(): string { | |
return this.generateGuid(); | |
} | |
private static generateGuid(): string { | |
return this.generatePart() + this.generatePart() + '-' + this.generatePart() + '-' + this.generatePart() + '-' + | |
this.generatePart() + '-' + this.generatePart() + this.generatePart() + this.generatePart(); | |
} | |
private static generatePart(): string { | |
return Math.floor((1 + Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment