Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | 2x 2x 6x 6x 6x 321x 293x 28x 636x 4x 28x 28x 28x 636x 6x 4x 6x 636x | import {Shell, ShellCommand, ShellOptions} from './Shell'; export class ShellControl { private input: number[] = []; private output: number[] = []; private shell: Shell; constructor( commands: {[commandName: string]: ShellCommand}, options: ShellOptions = {}, ) { this.shell = new Shell( { getChar: () => { if (this.input.length === 0) { return undefined; } return this.input.shift(); }, putChar: (char: number) => this.addToOutput(char), }, commands, options, ); } putString(strToPut: string): void { [...strToPut].forEach((charString: string) => { const char = charString.charCodeAt(0); this.putChar(char); }); } putChar(char: number): void { this.input.push(char); } addToOutput(char: number): void { this.output.push(char); } run(): void { this.shell.run(); } get numberInput(): number[] { return this.output; } get stringInput(): string { return this.input.map( (char: number) => String.fromCharCode(char), ).join(''); } get numberOutput(): number[] { return this.output; } get stringOutput(): string { return this.output.map( (char: number) => String.fromCharCode(char), ).join(''); } } |