Types src/content
This commit is contained in:
parent
992b3ac65d
commit
d01db82c0d
62 changed files with 1411 additions and 468 deletions
|
@ -1,5 +1,9 @@
|
|||
export default class HintKeyProducer {
|
||||
constructor(charset) {
|
||||
private charset: string;
|
||||
|
||||
private counter: number[];
|
||||
|
||||
constructor(charset: string) {
|
||||
if (charset.length === 0) {
|
||||
throw new TypeError('charset is empty');
|
||||
}
|
||||
|
@ -8,13 +12,13 @@ export default class HintKeyProducer {
|
|||
this.counter = [];
|
||||
}
|
||||
|
||||
produce() {
|
||||
produce(): string {
|
||||
this.increment();
|
||||
|
||||
return this.counter.map(x => this.charset[x]).join('');
|
||||
}
|
||||
|
||||
increment() {
|
||||
private increment(): void {
|
||||
let max = this.charset.length - 1;
|
||||
if (this.counter.every(x => x === max)) {
|
||||
this.counter = new Array(this.counter.length + 1).fill(0);
|
||||
|
|
Reference in a new issue