Commit 48ba3a4876c5ca8a507b2aca1a33c709c7feb5c9
throw error instead of fail silently
Dominic Tarr committed on 5/19/2016, 7:06:16 PMParent: 0317853c50ffacda585e8b019f18d3b8ff32329a
Files changed
util.js | changed |
util.js | ||
---|---|---|
@@ -16,9 +16,8 @@ | ||
16 | 16 | }, null) |
17 | 17 | } |
18 | 18 | |
19 | 19 | exports.first = first |
20 | - | |
21 | 20 | exports.decorate = decorate |
22 | 21 | |
23 | 22 | exports.next = function (createStream, opts, range, property) { |
24 | 23 | |
@@ -37,4 +36,14 @@ | ||
37 | 36 | }) |
38 | 37 | ) |
39 | 38 | }) |
40 | 39 | } |
40 | + | |
41 | +exports.firstPlug = function (plugs, fn) { | |
42 | + if(!Array.isArray(plugs)) throw new Error('plugs must be an array') | |
43 | + var args = [].slice.call(arguments) | |
44 | + var plugs = args.shift() | |
45 | + return exports.first(plugs, function (fn) { | |
46 | + return fn.apply(null, args) | |
47 | + }) | |
48 | +} | |
49 | + |
Built with git-ssb-web