forked from DebaucheryLibrarian/traxxx
23 lines
624 B
JavaScript
23 lines
624 B
JavaScript
|
'use strict';
|
||
|
|
||
|
const moment = require('moment');
|
||
|
|
||
|
const formatters = {
|
||
|
site: site => site.name,
|
||
|
date: (date, column) => moment(date).format(column.format || 'MMM DD, YYYY'),
|
||
|
actors: actors => actors.join(', '),
|
||
|
rating: (rating) => {
|
||
|
if (rating.stars === null) {
|
||
|
return 'Unrated';
|
||
|
}
|
||
|
|
||
|
if (rating.likes === null || rating.dislikes === null) {
|
||
|
return `★ ${rating.stars.toFixed(2)}`;
|
||
|
}
|
||
|
|
||
|
return `★ ${rating.stars.toFixed(2)} ▲ ${String(rating.likes).padEnd(3)} ▼ ${String(rating.dislikes).padEnd(3)}`;
|
||
|
},
|
||
|
};
|
||
|
|
||
|
module.exports = formatters;
|