import { PiecesState } from "../types" ; export const getPiecesWithoutIds = < TPiece > ( pieces , ids ) => { const newPieces = { ... pieces } ; for ( const pieceId of ids ) { if ( newPieces [ pieceId ] ) { delete newPieces [ pieceId ] ; } } return newPieces ; } ; export const getPiecePositionsWithoutIds = ( piecePositions , ids ) => Object . entries ( piecePositions ) . reduce < { [ position ] : string ; } > ( ( newPiecePositions , [ position , pieceId ] ) => { if ( ! pieceId || ids . includes ( pieceId ) ) { return newPiecePositions ; } newPiecePositions [ position ] = pieceId ; return newPiecePositions ; } , { } ) ;