Files: 00b7dc676f3599b4be16806c7ce93abbd9c724c5 / 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