From 0d1706f6788075c581198d8ef130c5035aa7eab2 Mon Sep 17 00:00:00 2001 From: cel Date: Mon, 12 Jun 2017 11:34:44 -1000 Subject: Move mergeOpts into util --- lib/serve.js | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index 3ade4f6..354e75f 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -594,8 +594,8 @@ Serve.prototype.syncPager = function (opts) { var max = (reverse ? opts.first : opts.last) || Number(q.lt) var minDate = new Date(min) var maxDate = new Date(max) - var qOlder = mergeOpts(q, {lt: min, gt: undefined, forwards: undefined}) - var qNewer = mergeOpts(q, {gt: max, lt: undefined, forwards: 1}) + var qOlder = u.mergeOpts(q, {lt: min, gt: undefined, forwards: undefined}) + var qNewer = u.mergeOpts(q, {gt: max, lt: undefined, forwards: 1}) var atNewest = reverse ? !q.lt : !max var atOldest = reverse ? !min : !q.gt if (atNewest && !reverse) qOlder.lt++ @@ -1125,31 +1125,19 @@ Serve.prototype.renderThread = function () { ) } -function mergeOpts(a, b) { - var obj = {}, k - for (k in a) { - obj[k] = a[k] - } - for (k in b) { - if (b[k] != null) obj[k] = b[k] - else delete obj[k] - } - return obj -} - Serve.prototype.renderThreadPaginated = function (opts, feedId, q) { var self = this function linkA(opts, name) { - var q1 = mergeOpts(q, opts) + var q1 = u.mergeOpts(q, opts) return h('a', {href: '?' + qs.stringify(q1)}, name || q1.limit) } function links(opts) { var limit = opts.limit || q.limit || 10 return h('tr', h('td.paginate', {colspan: 3}, opts.forwards ? '↑ newer ' : '↓ older ', - linkA(mergeOpts(opts, {limit: 1})), ' ', - linkA(mergeOpts(opts, {limit: 10})), ' ', - linkA(mergeOpts(opts, {limit: 100})) + linkA(u.mergeOpts(opts, {limit: 1})), ' ', + linkA(u.mergeOpts(opts, {limit: 10})), ' ', + linkA(u.mergeOpts(opts, {limit: 100})) )) } -- cgit v1.2.3