Skip to content

Commit

Permalink
IdGenerator converted to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
pludov committed Oct 30, 2018
1 parent 664e276 commit 7cd4d65
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions IdGenerator.js → IdGenerator.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@


// Generate id that are alphabetically sorted
class IdGenerator {
constructor()
export class IdGenerator {
private value: string;

constructor(from = "00000000")
{
this.value = "00000000";
this.value = from;
}


Expand All @@ -14,10 +16,9 @@ class IdGenerator {

next() {

function inc(str, at)
function inc(str:string, at:number)
{
var c = str.charCodeAt(at);
console.log('c=', c);
if (c >= 48 && c < 48 + 9) {
c++;
} else if (c == 48 + 9) {
Expand All @@ -41,5 +42,3 @@ class IdGenerator {
return this.value;
}
}

module.exports = {IdGenerator}

0 comments on commit 7cd4d65

Please sign in to comment.