-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
41 lines (33 loc) · 859 Bytes
/
index.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
'use strict';
let filters = require('./lib/filters');
let tags = require('./lib/tags');
module.exports = (type, options = {}) => {
if (type) {
let group = filters[type];
if (typeof group === 'function') {
return group(options);
}
return group;
}
let keys = Object.keys(filters);
let arr = keys.slice();
let names = [];
let res = {};
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
let group = filters[key];
if (typeof group === 'function') {
group = group(options);
}
for (let name of Object.keys(group)) {
// temporary code, for catching duplicates from different filter groups
if (names.includes(name)) {
console.log('duplicate:', name);
}
res[name] = group[name];
names.push(name);
}
}
return res;
};
module.exports.tags = tags;