Files: 251a4d7b1477eafd58a6093249e659cf49f23e0c / util.js
400 bytesRaw
1 | function first (list, test) { |
2 | for(var i in list) { |
3 | var value = test(list[i], i, list) |
4 | if(value) return value |
5 | } |
6 | } |
7 | |
8 | function decorate (list, value, caller) { |
9 | caller = caller || function (d,e,v) { return d(e, v) } |
10 | |
11 | return list.reduce(function (element, decorator) { |
12 | return caller(decorator, element, value) || element |
13 | }, null) |
14 | } |
15 | |
16 | exports.first = first |
17 | |
18 | exports.decorate = decorate |
19 |
Built with git-ssb-web