-
Notifications
You must be signed in to change notification settings - Fork 5
/
utils.js
40 lines (32 loc) · 882 Bytes
/
utils.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const views = require('co-views');
module.exports.Render = views(__dirname + '/views', {
map: { html: 'swig' }
});
class AlphabeticalSortStrategy {
static sort(notices) {
let nots = notices.slice();
nots.sort(function(a, b) {
var nameA = a.message.toUpperCase(); // ignore upper and lowercase
var nameB = b.message.toUpperCase(); // ignore upper and lowercase
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
// names must be equal
return 0;
});
return nots;
}
}
module.exports.AlphabeticalSortStrategy = AlphabeticalSortStrategy;
class ReverseChronologicalSortStrategy {
static sort(notices) {
let nots = notices.slice();
nots.reverse();
return nots;
}
}
module.exports.ReverseChronologicalSortStrategy = ReverseChronologicalSortStrategy;