Skip to content

Commit

Permalink
#410: typescript config files
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Buhtoyarov committed May 5, 2024
1 parent 1a47b97 commit 0f1f815
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 178 deletions.
2 changes: 1 addition & 1 deletion typescript/config/webpack.config.js
Expand Up @@ -2,7 +2,7 @@ const path = require('path')

module.exports = {
mode: 'production',
entry: './src/index.ts',
entry: './src/Bucket4j.ts',
output: {
path: path.resolve(__dirname, '../dist/umd'),
filename: 'index.js',
Expand Down
File renamed without changes.
177 changes: 0 additions & 177 deletions typescript/src/Num.ts

This file was deleted.

66 changes: 66 additions & 0 deletions typescript/src/common/Bandwidth.ts
@@ -0,0 +1,66 @@
export class Bandwidth {

public static readonly UNDEFINED_ID:string? = null;
public static readonly UNSPECIFIED_TIME_OF_FIRST_REFILL:bigint = BigInt(0);

private readonly capacity:bigint
private readonly initialTokens:bigint
private readonly refillPeriodNanos:bigint
private readonly refillTokens:bigint
private readonly refillIntervally:boolean
private readonly timeOfFirstRefillMillis:bigint
private readonly useAdaptiveInitialTokens:boolean
private readonly id:string

constructor(capacity:bigint, refillPeriodNanos:bigint, refillTokens:bigint, initialTokens:bigint, refillIntervally:boolean,
timeOfFirstRefillMillis:bigint, useAdaptiveInitialTokens:boolean, id:string) {
this.capacity = capacity;
this.initialTokens = initialTokens;
this.refillPeriodNanos = refillPeriodNanos;
this.refillTokens = refillTokens;
this.refillIntervally = refillIntervally;
this.timeOfFirstRefillMillis = timeOfFirstRefillMillis;
this.useAdaptiveInitialTokens = useAdaptiveInitialTokens;
this.id = id;
}

public isIntervallyAligned():boolean {
return this.timeOfFirstRefillMillis != Bandwidth.UNSPECIFIED_TIME_OF_FIRST_REFILL;
}

public getTimeOfFirstRefillMillis():bigint {
return this.timeOfFirstRefillMillis;
}

public getCapacity():bigint {
return this.capacity;
}

public getInitialTokens():bigint {
return this.initialTokens;
}

public getRefillPeriodNanos():bigint {
return this.refillPeriodNanos;
}

public getRefillTokens():bigint {
return this.refillTokens;
}

public isUseAdaptiveInitialTokens():boolean {
return this.useAdaptiveInitialTokens;
}

public isRefillIntervally():boolean {
return this.refillIntervally;
}

public isGready():boolean {
return !this.refillIntervally;
}

public getId():string {
return this.id;
}
}

0 comments on commit 0f1f815

Please sign in to comment.