Skip to content

Commit

Permalink
#3 cleanup code, remove untestable code: `if (!this.cells.includes(ty…
Browse files Browse the repository at this point in the history
…pe)){...}`

`
  • Loading branch information
Pawel Siemienik committed Apr 18, 2020
1 parent d6ccda6 commit 73c58fc
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/CellTemplatePool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,7 @@ export class CellTemplatePool {
protected instances: { [key: string]: BaseCell } = {};

public match(cell: Cell): BaseCell {
const type = this.cells.find(x => x.match(cell));

return type ? this.getInstance(type) : this.getInstance(NormalCell);
}

private getInstance(type: CellType): BaseCell {
if (!this.cells.includes(type)) {
throw new TypeError(`parameter 'type' has to included in [${this.cells.map(x => x.name)}]`);
}
const type = this.cells.find(x => x.match(cell)) || NormalCell;

if (!this.instances[type.name]) {
this.instances[type.name] = new type();
Expand Down

0 comments on commit 73c58fc

Please sign in to comment.