-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
40 lines (33 loc) · 769 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
'use strict';
/*!
* template-helpers <https://github.com/jonschlinkert/template-helpers>
*
* Copyright (c) 2015-present, Jon Schlinkert.
* Licensed under the MIT License.
*/
const helpers = require('./lib/helpers');
module.exports = key => {
let res = {};
if (typeof key === 'string') {
res = helpers[key];
res[key] = res;
return res;
}
if (Array.isArray(key)) {
return key.reduce((acc, k) => {
acc[k] = helpers[k];
for (let prop of Object.keys(acc[k])) {
acc[prop] = acc[k][prop];
}
return acc;
}, {});
}
for (let prop of Object.keys(helpers)) {
let group = helpers[prop];
res[prop] = group;
for (let k of Object.keys(group)) {
res[k] = group[k];
}
}
return res;
};