From d557a21d900a1321bed19bc6415fedbdce61e6ce Mon Sep 17 00:00:00 2001 From: Jonny Date: Fri, 3 May 2019 12:00:25 +0200 Subject: [PATCH] Extract the ranged map function --- js/utils/rangedmap.js | 4 ++++ pages/tournament-statistics.js | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 js/utils/rangedmap.js diff --git a/js/utils/rangedmap.js b/js/utils/rangedmap.js new file mode 100644 index 0000000..1373ebe --- /dev/null +++ b/js/utils/rangedmap.js @@ -0,0 +1,4 @@ + +export function rangedmap(arr, func, start, end) { + return arr.slice(start, end).map(func); +} diff --git a/pages/tournament-statistics.js b/pages/tournament-statistics.js index 221fe49..dcfc34f 100644 --- a/pages/tournament-statistics.js +++ b/pages/tournament-statistics.js @@ -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 { - { map(sortedPerformances, (team, index) => ( + { rangedmap(sortedPerformances, (team, index) => ( ), 0, 3) } - { map(sortedPerformances, (team, index) => ( + { rangedmap(sortedPerformances, (team, index) => ( ), 3) } @@ -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 {