diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/page/album-commentary.js | 5 | ||||
-rw-r--r-- | src/util/wiki-data.js | 7 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/page/album-commentary.js b/src/page/album-commentary.js index a0ac8d94..50a2aa39 100644 --- a/src/page/album-commentary.js +++ b/src/page/album-commentary.js @@ -1,5 +1,6 @@ // Album commentary page and index specifications. +import {accumulateSum} from '../util/sugar.js'; import {filterAlbumsByCommentary} from '../util/wiki-data.js'; export function condition({wikiData}) { @@ -93,8 +94,8 @@ export function writeTargetless({wikiData}) { words: entries.join(' ').split(' ').length, })); - const totalEntries = data.reduce((acc, {entries}) => acc + entries.length, 0); - const totalWords = data.reduce((acc, {words}) => acc + words, 0); + const totalEntries = accumulateSum(data, ({entries}) => entries.length); + const totalWords = accumulateSum(data, ({words}) => words); const page = { type: 'page', diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index 7d2cfa9f..f044b2a1 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -1,6 +1,9 @@ // Utility functions for interacting with wiki data. -import {empty} from './sugar.js'; +import { + accumulateSum, + empty, +} from './sugar.js'; // Generic value operations @@ -382,7 +385,7 @@ export function getFlashLink(flash) { } export function getTotalDuration(tracks) { - return tracks.reduce((duration, track) => duration + track.duration, 0); + return accumulateSum(tracks, track => track.duration); } export function getTrackCover(track, {to}) { |