mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-13 02:55:24 +08:00
38 lines
846 B
JavaScript
38 lines
846 B
JavaScript
import { AbstractCollectionModel } from 'Model/AbstractCollection';
|
|
import { MimeHeaderModel } from 'Model/MimeHeader';
|
|
|
|
'use strict';
|
|
|
|
export class MimeHeaderCollectionModel extends AbstractCollectionModel
|
|
{
|
|
/**
|
|
* @param {?Array} json
|
|
* @returns {MimeHeaderCollectionModel}
|
|
*/
|
|
static reviveFromJson(items) {
|
|
return super.reviveFromJson(items, header => MimeHeaderModel.reviveFromJson(header));
|
|
}
|
|
|
|
/**
|
|
* @param {string} name
|
|
* @returns {?MimeHeader}
|
|
*/
|
|
getByName(name)
|
|
{
|
|
name = name.toLowerCase();
|
|
return this.find(header => header.name.toLowerCase() === name);
|
|
}
|
|
|
|
valueByName(name)
|
|
{
|
|
const header = this.getByName(name);
|
|
return header ? header.value : '';
|
|
}
|
|
|
|
valuesByName(name)
|
|
{
|
|
name = name.toLowerCase();
|
|
return this.filter(header => header.name.toLowerCase() === name).map(header => header.value);
|
|
}
|
|
|
|
}
|