Extract the ranged map function

This commit is contained in:
Jonny 2019-05-03 12:00:25 +02:00 committed by JP1998
parent 7c1928dce3
commit d557a21d90
2 changed files with 7 additions and 4 deletions

4
js/utils/rangedmap.js Normal file
View File

@ -0,0 +1,4 @@
export function rangedmap(arr, func, start, end) {
return arr.slice(start, end).map(func);
}

View File

@ -19,6 +19,7 @@ import { TurniereNavigation } from '../js/components/Navigation';
import { TournamentInformationView } from '../js/components/TournamentInformationView';
import { BigImage } from '../js/components/BigImage';
import { Footer } from '../js/components/Footer';
import { rangedmap } from '../js/utils/rangedmap';
import { Order, sort } from '../js/utils/sort';
import '../static/css/tournament-statistics.css';
@ -115,12 +116,12 @@ class StandingsTable extends React.Component {
</tr>
</thead>
<tbody>
{ map(sortedPerformances, (team, index) => (
{ rangedmap(sortedPerformances, (team, index) => (
<TeamRow key={index} teams={this.props.data.teams} teamToShow={team}/>
), 0, 3) }
</tbody>
<Collapse isOpen={ this.state.showFullTable } tag="tbody">
{ map(sortedPerformances, (team, index) => (
{ rangedmap(sortedPerformances, (team, index) => (
<TeamRow key={index} teams={this.props.data.teams} teamToShow={team}/>
), 3) }
</Collapse>
@ -142,8 +143,6 @@ class StandingsTable extends React.Component {
}
}
function map(arr, func, start, end) {
return arr.slice(start, end).map(func);
}
class TableButton extends React.Component {