mirror of
https://github.com/overleaf/overleaf.git
synced 2024-09-16 02:52:31 -04:00
Decaf cleanup: simplify loops
This commit is contained in:
parent
e9df9714e5
commit
05a2cf829c
1 changed files with 8 additions and 28 deletions
|
@ -2,13 +2,6 @@
|
||||||
camelcase,
|
camelcase,
|
||||||
handle-callback-err,
|
handle-callback-err,
|
||||||
*/
|
*/
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Fix any style issues and re-enable lint.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS101: Remove unnecessary use of Array.from
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
let DocUpdaterClient
|
let DocUpdaterClient
|
||||||
const Settings = require('settings-sharelatex')
|
const Settings = require('settings-sharelatex')
|
||||||
const rclient = require('redis-sharelatex').createClient(
|
const rclient = require('redis-sharelatex').createClient(
|
||||||
|
@ -26,10 +19,11 @@ rclient_sub.setMaxListeners(0)
|
||||||
|
|
||||||
module.exports = DocUpdaterClient = {
|
module.exports = DocUpdaterClient = {
|
||||||
randomId() {
|
randomId() {
|
||||||
const chars = __range__(1, 24, true).map(
|
let str = ''
|
||||||
(i) => Math.random().toString(16)[2]
|
for (let i = 0; i < 24; i++) {
|
||||||
)
|
str += Math.floor(Math.random() * 16).toString(16)
|
||||||
return chars.join('')
|
}
|
||||||
|
return str
|
||||||
},
|
},
|
||||||
|
|
||||||
subscribeToAppliedOps(callback) {
|
subscribeToAppliedOps(callback) {
|
||||||
|
@ -60,13 +54,9 @@ module.exports = DocUpdaterClient = {
|
||||||
if (error) {
|
if (error) {
|
||||||
return callback(error)
|
return callback(error)
|
||||||
}
|
}
|
||||||
const jobs = []
|
const jobs = updates.map((update) => (callback) => {
|
||||||
for (const update of Array.from(updates)) {
|
DocUpdaterClient.sendUpdate(project_id, doc_id, update, callback)
|
||||||
;((update) =>
|
})
|
||||||
jobs.push((callback) =>
|
|
||||||
DocUpdaterClient.sendUpdate(project_id, doc_id, update, callback)
|
|
||||||
))(update)
|
|
||||||
}
|
|
||||||
async.series(jobs, (err) =>
|
async.series(jobs, (err) =>
|
||||||
DocUpdaterClient.waitForPendingUpdates(project_id, doc_id, callback)
|
DocUpdaterClient.waitForPendingUpdates(project_id, doc_id, callback)
|
||||||
)
|
)
|
||||||
|
@ -210,13 +200,3 @@ module.exports = DocUpdaterClient = {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function __range__(left, right, inclusive) {
|
|
||||||
const range = []
|
|
||||||
const ascending = left < right
|
|
||||||
const end = !inclusive ? right : ascending ? right + 1 : right - 1
|
|
||||||
for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) {
|
|
||||||
range.push(i)
|
|
||||||
}
|
|
||||||
return range
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue