summaryrefslogtreecommitdiffstats
path: root/lib/modifiers/summary/editPartTitle.js
blob: b79ac1e480be017411fde2f7307750ee2ee0c328 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
    Edit title of a part in the summary

    @param {Summary} summary
    @param {Number} index
    @param {String} newTitle
    @return {Summary}
*/
function editPartTitle(summary, index, newTitle) {
    var parts = summary.getParts();

    var part = parts.get(index);
    if (!part) {
        return summary;
    }

    part = part.set('title', newTitle);
    parts = parts.set(index, part);

    return summary.set('parts', parts);
}

module.exports = editPartTitle;