1 | function get(fn, defaultValue) {
|
2 | const types = ['string', 'number', 'boolean'];
|
3 | try {
|
4 | const value = fn();
|
5 | return types.includes(typeof value) ? value : defaultValue;
|
6 | } catch (e) {
|
7 | return defaultValue;
|
8 | }
|
9 | }
|
10 |
|
11 | module.exports = {
|
12 | get,
|
13 | };
|