This repository has been archived by the owner on Nov 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfilters.js
75 lines (65 loc) · 1.98 KB
/
filters.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
***** BEGIN LICENSE BLOCK *****
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The Initial Developer of the Original Code is the Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Rob Miller ([email protected])
*
***** END LICENSE BLOCK *****
*/
"use strict";
var severityMaxProvider = function(config) {
var severityMax = function(msg) {
if (msg['severity'] > config['severity']) {
return false;
};
return true;
};
return severityMax;
};
var typeBlacklistProvider = function(config) {
var typeBlacklist = function(msg) {
if (msg['type'] in config['types']) {
return false;
};
return true;
};
return typeBlacklist;
};
var typeWhitelistProvider = function(config) {
var typeWhitelist = function(msg) {
if (!(msg['type'] in config['types'])) {
return false;
};
return true;
};
return typeWhitelist;
};
var typeSeverityMaxProvider = function(config) {
var typeFilters = {};
var typeName = null;
for (typeName in config.types) {
if (config.types.hasOwnProperty(typeName)) {
var typeConfig = config.types[typeName];
typeFilters[typeName] = severityMaxProvider(typeConfig);
};
};
var typeSeverityMax = function(msg) {
var severityMax = typeFilters[msg['type']];
if (severityMax === undefined) {
return true;
};
return severityMax(msg);
};
return typeSeverityMax;
};
exports.severityMaxProvider = severityMaxProvider;
exports.typeBlacklistProvider = typeBlacklistProvider;
exports.typeWhitelistProvider = typeWhitelistProvider;
exports.typeSeverityMaxProvider = typeSeverityMaxProvider;