Allow TS to import countShips internally
This commit is contained in:
parent
762e2bdb1b
commit
1167c10707
1 changed files with 4 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
/**
|
/**
|
||||||
|
* @internal
|
||||||
* A helper method for counting how many ships are on each side of a specific
|
* A helper method for counting how many ships are on each side of a specific
|
||||||
* ship on the board.
|
* ship on the board.
|
||||||
*
|
*
|
||||||
|
|
@ -8,7 +9,7 @@
|
||||||
* @returns An object containing the number of ships that are on each side of
|
* @returns An object containing the number of ships that are on each side of
|
||||||
* the target ship
|
* the target ship
|
||||||
*/
|
*/
|
||||||
function countShips(board: any[], shipLocation: number) {
|
export function countShips(board: any[], shipLocation: number) {
|
||||||
return {
|
return {
|
||||||
left: board.slice(1, shipLocation - 1).filter(x => x != null).length,
|
left: board.slice(1, shipLocation - 1).filter(x => x != null).length,
|
||||||
right: board.slice(shipLocation + 1).filter(x => x != null).length,
|
right: board.slice(shipLocation + 1).filter(x => x != null).length,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue