Skip to content

Instantly share code, notes, and snippets.

@jonocairns
Created April 30, 2015 20:55
Show Gist options
  • Save jonocairns/fa258c1faadced9f86dd to your computer and use it in GitHub Desktop.
Save jonocairns/fa258c1faadced9f86dd to your computer and use it in GitHub Desktop.
'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