Skip to content

Commit

Permalink
Use reduce to only grab properties with values.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev committed Oct 26, 2015
1 parent 1250e75 commit 183d56c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/js/tracks/text-track-list-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@
* @private
*/
let trackToJson_ = function(track) {
let ret = {
kind: track.kind,
label: track.label,
language: track.language,
id: track.id,
inBandMetadataTrackDispatchType: track.inBandMetadataTrackDispatchType,
mode: track.mode,
let ret = ['kind', 'label', 'language', 'id',
'inBandMetadataTrackDispatchType',
'mode', 'src'].reduce((acc, prop, i) => {
if (track[prop]) {
acc[prop] = track[prop];
}

return acc;
}, {
cues: track.cues && Array.prototype.map.call(track.cues, function(cue) {
return {
startTime: cue.startTime,
endTime: cue.endTime,
text: cue.text,
id: cue.id
};
}),
};
if (track.src) {
ret.src = track.src;
}
})
});

return ret;
};

Expand Down

0 comments on commit 183d56c

Please sign in to comment.