Files: 7c6dab1d9d68e8ade63c36289e36b97c671b6579 / util.js
416 bytesRaw
1 | exports.id = |
2 | function (item) { |
3 | return item |
4 | } |
5 | |
6 | exports.prop = |
7 | function (map) { |
8 | if('string' == typeof map) { |
9 | var key = map |
10 | return function (data) { return data[key] } |
11 | } |
12 | return map |
13 | } |
14 | |
15 | exports.tester = function (test) { |
16 | if(!test) return exports.id |
17 | if('object' === typeof test |
18 | && 'function' === typeof test.test) |
19 | return test.test.bind(test) |
20 | return exports.prop(test) || exports.id |
21 | } |
22 | |
23 | |
24 |
Built with git-ssb-web