From dad1d1212f42fe9d70dc6edd3bc2712f6a585266 Mon Sep 17 00:00:00 2001 From: decaffeinate Date: Wed, 6 May 2020 12:09:15 +0200 Subject: [PATCH] decaffeinate: Run post-processing cleanups on DeleteQueueManager.coffee and 58 other files --- .../app/coffee/DeleteQueueManager.js | 9 ++++- .../document-updater/app/coffee/DiffCodec.js | 11 +++++- .../app/coffee/DispatchManager.js | 9 ++++- .../app/coffee/DocumentManager.js | 9 ++++- .../document-updater/app/coffee/Errors.js | 6 +++ .../app/coffee/HistoryManager.js | 6 +++ .../app/coffee/HistoryRedisManager.js | 7 ++++ .../app/coffee/HttpController.js | 10 ++++- .../app/coffee/LockManager.js | 7 ++++ .../app/coffee/LoggerSerializers.js | 5 +++ .../document-updater/app/coffee/Metrics.js | 2 + .../app/coffee/PersistenceManager.js | 8 ++++ .../document-updater/app/coffee/Profiler.js | 7 +++- .../app/coffee/ProjectFlusher.js | 10 ++++- .../app/coffee/ProjectHistoryRedisManager.js | 10 ++++- .../app/coffee/ProjectManager.js | 13 +++++-- .../app/coffee/RangesManager.js | 16 +++++--- .../app/coffee/RangesTracker.js | 38 +++++++++++-------- .../app/coffee/RateLimitManager.js | 5 +++ .../app/coffee/RealTimeRedisManager.js | 6 +++ .../app/coffee/RedisManager.js | 8 +++- .../document-updater/app/coffee/ShareJsDB.js | 6 +++ .../app/coffee/ShareJsUpdateManager.js | 7 ++++ .../app/coffee/SnapshotManager.js | 10 ++++- .../document-updater/app/coffee/UpdateKeys.js | 5 +++ .../app/coffee/UpdateManager.js | 13 +++++-- .../document-updater/app/coffee/mongojs.js | 2 + .../app/coffee/sharejs/count.js | 2 + .../app/coffee/sharejs/helpers.js | 14 +++++-- .../app/coffee/sharejs/index.js | 2 + .../app/coffee/sharejs/json-api.js | 13 +++++-- .../app/coffee/sharejs/json.js | 15 ++++++-- .../app/coffee/sharejs/model.js | 19 +++++++--- .../app/coffee/sharejs/server/model.js | 19 +++++++--- .../app/coffee/sharejs/server/syncqueue.js | 2 + .../app/coffee/sharejs/simple.js | 4 +- .../app/coffee/sharejs/syncqueue.js | 2 + .../app/coffee/sharejs/text-api.js | 2 + .../app/coffee/sharejs/text-composable-api.js | 7 +++- .../app/coffee/sharejs/text-composable.js | 30 +++++++++------ .../app/coffee/sharejs/text-tp2-api.js | 9 ++++- .../app/coffee/sharejs/text-tp2.js | 18 ++++++--- .../app/coffee/sharejs/text.js | 17 ++++++--- .../app/coffee/sharejs/types/count.js | 2 + .../app/coffee/sharejs/types/helpers.js | 14 +++++-- .../app/coffee/sharejs/types/index.js | 2 + .../app/coffee/sharejs/types/json-api.js | 13 +++++-- .../app/coffee/sharejs/types/json.js | 15 ++++++-- .../app/coffee/sharejs/types/model.js | 19 +++++++--- .../app/coffee/sharejs/types/simple.js | 4 +- .../app/coffee/sharejs/types/syncqueue.js | 2 + .../app/coffee/sharejs/types/text-api.js | 2 + .../sharejs/types/text-composable-api.js | 7 +++- .../coffee/sharejs/types/text-composable.js | 30 +++++++++------ .../app/coffee/sharejs/types/text-tp2-api.js | 9 ++++- .../app/coffee/sharejs/types/text-tp2.js | 18 ++++++--- .../app/coffee/sharejs/types/text.js | 17 ++++++--- .../app/coffee/sharejs/types/web-prelude.js | 7 +++- .../app/coffee/sharejs/web-prelude.js | 7 +++- 59 files changed, 456 insertions(+), 132 deletions(-) diff --git a/services/document-updater/app/coffee/DeleteQueueManager.js b/services/document-updater/app/coffee/DeleteQueueManager.js index 2b6230100a..a970f5825f 100644 --- a/services/document-updater/app/coffee/DeleteQueueManager.js +++ b/services/document-updater/app/coffee/DeleteQueueManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// 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 @@ -41,7 +48,7 @@ module.exports = (DeleteQueueManager = { return cb(); } // are any of the timestamps newer than the time the project was flushed? - for (let timestamp of Array.from(timestamps)) { + for (const timestamp of Array.from(timestamps)) { if (timestamp > flushTimestamp) { metrics.inc("queued-delete-skipped"); logger.debug({project_id, timestamps, flushTimestamp}, "found newer timestamp, will skip delete"); diff --git a/services/document-updater/app/coffee/DiffCodec.js b/services/document-updater/app/coffee/DiffCodec.js index c5c99b7acc..8b87cee1d3 100644 --- a/services/document-updater/app/coffee/DiffCodec.js +++ b/services/document-updater/app/coffee/DiffCodec.js @@ -1,3 +1,12 @@ +/* eslint-disable + camelcase, + handle-callback-err, + new-cap, + no-throw-literal, + no-unused-vars, +*/ +// 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 @@ -23,7 +32,7 @@ module.exports = (DiffCodec = { const ops = []; let position = 0; - for (let diff of Array.from(diffs)) { + for (const diff of Array.from(diffs)) { const type = diff[0]; const content = diff[1]; if (type === this.ADDED) { diff --git a/services/document-updater/app/coffee/DispatchManager.js b/services/document-updater/app/coffee/DispatchManager.js index 3bf343dd2e..8f11378a9c 100644 --- a/services/document-updater/app/coffee/DispatchManager.js +++ b/services/document-updater/app/coffee/DispatchManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// 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 @@ -71,7 +78,7 @@ module.exports = (DispatchManager = { const RateLimiter = new RateLimitManager(number); return (() => { const result = []; - for (let i = 1, end = number, asc = 1 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) { + for (let i = 1, end = number, asc = end >= 1; asc ? i <= end : i >= end; asc ? i++ : i--) { const worker = DispatchManager.createDispatcher(RateLimiter); result.push(worker.run()); } diff --git a/services/document-updater/app/coffee/DocumentManager.js b/services/document-updater/app/coffee/DocumentManager.js index c5a9ebb3d1..d1e3e3ca07 100644 --- a/services/document-updater/app/coffee/DocumentManager.js +++ b/services/document-updater/app/coffee/DocumentManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// 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 @@ -96,7 +103,7 @@ module.exports = (DocumentManager = { return DiffCodec.diffAsShareJsOp(oldLines, newLines, function(error, op) { if (error != null) { return callback(error); } if (undoing) { - for (let o of Array.from(op || [])) { + for (const o of Array.from(op || [])) { o.u = true; } // Turn on undo flag for each op for track changes } diff --git a/services/document-updater/app/coffee/Errors.js b/services/document-updater/app/coffee/Errors.js index a8cb2efb1d..d4bbfb7acc 100644 --- a/services/document-updater/app/coffee/Errors.js +++ b/services/document-updater/app/coffee/Errors.js @@ -1,3 +1,9 @@ +/* eslint-disable + no-proto, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. let Errors; var NotFoundError = function(message) { const error = new Error(message); diff --git a/services/document-updater/app/coffee/HistoryManager.js b/services/document-updater/app/coffee/HistoryManager.js index ac9ba9a706..457e8247fb 100644 --- a/services/document-updater/app/coffee/HistoryManager.js +++ b/services/document-updater/app/coffee/HistoryManager.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + handle-callback-err, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/HistoryRedisManager.js b/services/document-updater/app/coffee/HistoryRedisManager.js index 6e2aba403c..a63d80b11c 100644 --- a/services/document-updater/app/coffee/HistoryRedisManager.js +++ b/services/document-updater/app/coffee/HistoryRedisManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/HttpController.js b/services/document-updater/app/coffee/HttpController.js index dfc749eeb9..4dc1622b43 100644 --- a/services/document-updater/app/coffee/HttpController.js +++ b/services/document-updater/app/coffee/HttpController.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + 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 @@ -58,7 +64,7 @@ module.exports = (HttpController = { _getTotalSizeOfLines(lines) { let size = 0; - for (let line of Array.from(lines)) { + for (const line of Array.from(lines)) { size += (line.length + 1); } return size; @@ -75,7 +81,7 @@ module.exports = (HttpController = { logger.log({project_id, exclude: excludeItems}, "getting docs via http"); const timer = new Metrics.Timer("http.getAllDocs"); const excludeVersions = {}; - for (let item of Array.from(excludeItems)) { + for (const item of Array.from(excludeItems)) { const [id,version] = Array.from(item != null ? item.split(':') : undefined); excludeVersions[id] = version; } diff --git a/services/document-updater/app/coffee/LockManager.js b/services/document-updater/app/coffee/LockManager.js index 2b278c31e4..a861ed8607 100644 --- a/services/document-updater/app/coffee/LockManager.js +++ b/services/document-updater/app/coffee/LockManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-return-assign, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/LoggerSerializers.js b/services/document-updater/app/coffee/LoggerSerializers.js index 87696abf3a..bd55383fd3 100644 --- a/services/document-updater/app/coffee/LoggerSerializers.js +++ b/services/document-updater/app/coffee/LoggerSerializers.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-return-assign, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/Metrics.js b/services/document-updater/app/coffee/Metrics.js index 8a46f7aa83..d5bfb88492 100644 --- a/services/document-updater/app/coffee/Metrics.js +++ b/services/document-updater/app/coffee/Metrics.js @@ -1 +1,3 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. module.exports = require("metrics-sharelatex"); \ No newline at end of file diff --git a/services/document-updater/app/coffee/PersistenceManager.js b/services/document-updater/app/coffee/PersistenceManager.js index f981f6bf90..2a9e5e9d04 100644 --- a/services/document-updater/app/coffee/PersistenceManager.js +++ b/services/document-updater/app/coffee/PersistenceManager.js @@ -1,3 +1,11 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unsafe-negation, + no-unused-vars, +*/ +// 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 diff --git a/services/document-updater/app/coffee/Profiler.js b/services/document-updater/app/coffee/Profiler.js index 2ca3484496..23e480bea8 100644 --- a/services/document-updater/app/coffee/Profiler.js +++ b/services/document-updater/app/coffee/Profiler.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS206: Consider reworking classes to avoid initClass @@ -39,7 +44,7 @@ module.exports = (Profiler = (function() { const totalTime = deltaMs(this.t, this.t0); if (totalTime > this.LOG_CUTOFF_TIME) { // log anything greater than cutoff const args = {}; - for (let k in this.args) { + for (const k in this.args) { const v = this.args[k]; args[k] = v; } diff --git a/services/document-updater/app/coffee/ProjectFlusher.js b/services/document-updater/app/coffee/ProjectFlusher.js index d42eb59531..ef7bb834c2 100644 --- a/services/document-updater/app/coffee/ProjectFlusher.js +++ b/services/document-updater/app/coffee/ProjectFlusher.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + no-unused-vars, +*/ +// 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 @@ -39,7 +45,7 @@ var ProjectFlusher = { let keys; if (error != null) { return callback(error); } [cursor, keys] = Array.from(reply); - for (let key of Array.from(keys)) { + for (const key of Array.from(keys)) { keySet[key] = true; } keys = Object.keys(keySet); @@ -59,7 +65,7 @@ var ProjectFlusher = { _extractIds(keyList) { const ids = (() => { const result = []; - for (let key of Array.from(keyList)) { + for (const key of Array.from(keyList)) { const m = key.match(/:\{?([0-9a-f]{24})\}?/); // extract object id result.push(m[1]); } diff --git a/services/document-updater/app/coffee/ProjectHistoryRedisManager.js b/services/document-updater/app/coffee/ProjectHistoryRedisManager.js index cccacba2d2..de19542227 100644 --- a/services/document-updater/app/coffee/ProjectHistoryRedisManager.js +++ b/services/document-updater/app/coffee/ProjectHistoryRedisManager.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + 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 @@ -17,8 +23,8 @@ const metrics = require('./Metrics'); module.exports = (ProjectHistoryRedisManager = { queueOps(project_id, ...rest) { // Record metric for ops pushed onto queue - const adjustedLength = Math.max(rest.length, 1), ops = rest.slice(0, adjustedLength - 1), val = rest[adjustedLength - 1], callback = val != null ? val : function(error, projectUpdateCount) {}; - for (let op of Array.from(ops)) { + const adjustedLength = Math.max(rest.length, 1); const ops = rest.slice(0, adjustedLength - 1); const val = rest[adjustedLength - 1]; const callback = val != null ? val : function(error, projectUpdateCount) {}; + for (const op of Array.from(ops)) { metrics.summary("redis.projectHistoryOps", op.length, {status: "push"}); } const multi = rclient.multi(); diff --git a/services/document-updater/app/coffee/ProjectManager.js b/services/document-updater/app/coffee/ProjectManager.js index 8b45b7d32d..deac1e451a 100644 --- a/services/document-updater/app/coffee/ProjectManager.js +++ b/services/document-updater/app/coffee/ProjectManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// 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 @@ -28,7 +35,7 @@ module.exports = (ProjectManager = { if (error != null) { return callback(error); } const jobs = []; const errors = []; - for (let doc_id of Array.from((doc_ids || []))) { + for (const doc_id of Array.from((doc_ids || []))) { ((doc_id => jobs.push(callback => DocumentManager.flushDocIfLoadedWithLock(project_id, doc_id, function(error) { if ((error != null) && error instanceof Errors.NotFoundError) { logger.warn({err: error, project_id, doc_id}, "found deleted doc when flushing"); @@ -66,7 +73,7 @@ module.exports = (ProjectManager = { if (error != null) { return callback(error); } const jobs = []; const errors = []; - for (let doc_id of Array.from((doc_ids || []))) { + for (const doc_id of Array.from((doc_ids || []))) { ((doc_id => jobs.push(callback => DocumentManager.flushAndDeleteDocWithLock(project_id, doc_id, {}, function(error) { if (error != null) { logger.error({err: error, project_id, doc_id}, "error deleting doc"); @@ -142,7 +149,7 @@ module.exports = (ProjectManager = { return callback(error); } const jobs = []; - for (let doc_id of Array.from(doc_ids || [])) { + for (const doc_id of Array.from(doc_ids || [])) { ((doc_id => jobs.push(cb => // get the doc lines from redis DocumentManager.getDocAndFlushIfOldWithLock(project_id, doc_id, function(err, lines, version) { if (err != null) { diff --git a/services/document-updater/app/coffee/RangesManager.js b/services/document-updater/app/coffee/RangesManager.js index 83523f33b5..f5890f5ad3 100644 --- a/services/document-updater/app/coffee/RangesManager.js +++ b/services/document-updater/app/coffee/RangesManager.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + 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 @@ -22,12 +28,12 @@ module.exports = (RangesManager = { const {changes, comments} = _.cloneDeep(entries); const rangesTracker = new RangesTracker(changes, comments); const emptyRangeCountBefore = RangesManager._emptyRangesCount(rangesTracker); - for (let update of Array.from(updates)) { + for (const update of Array.from(updates)) { rangesTracker.track_changes = !!update.meta.tc; - if (!!update.meta.tc) { + if (update.meta.tc) { rangesTracker.setIdSeed(update.meta.tc); } - for (let op of Array.from(update.op)) { + for (const op of Array.from(update.op)) { try { rangesTracker.applyOp(op, { user_id: (update.meta != null ? update.meta.user_id : undefined) }); } catch (error1) { @@ -95,12 +101,12 @@ module.exports = (RangesManager = { _emptyRangesCount(ranges) { let count = 0; - for (let comment of Array.from((ranges.comments || []))) { + for (const comment of Array.from((ranges.comments || []))) { if (comment.op.c === "") { count++; } } - for (let change of Array.from((ranges.changes || []))) { + for (const change of Array.from((ranges.changes || []))) { if (change.op.i != null) { if (change.op.i === "") { count++; diff --git a/services/document-updater/app/coffee/RangesTracker.js b/services/document-updater/app/coffee/RangesTracker.js index de7e885c5c..80422ec54f 100644 --- a/services/document-updater/app/coffee/RangesTracker.js +++ b/services/document-updater/app/coffee/RangesTracker.js @@ -1,3 +1,11 @@ +/* eslint-disable + camelcase, + no-return-assign, + no-undef, + no-unused-vars, +*/ +// 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 @@ -88,7 +96,7 @@ const load = function() { getComment(comment_id) { let comment = null; - for (let c of Array.from(this.comments)) { + for (const c of Array.from(this.comments)) { if (c.id === comment_id) { comment = c; break; @@ -107,7 +115,7 @@ const load = function() { moveCommentId(comment_id, position, text) { return (() => { const result = []; - for (let comment of Array.from(this.comments)) { + for (const comment of Array.from(this.comments)) { if (comment.id === comment_id) { comment.op.p = position; comment.op.c = text; @@ -122,7 +130,7 @@ const load = function() { getChange(change_id) { let change = null; - for (let c of Array.from(this.changes)) { + for (const c of Array.from(this.changes)) { if (c.id === change_id) { change = c; break; @@ -135,11 +143,11 @@ const load = function() { const changes_response = []; const ids_map = {}; - for (let change_id of Array.from(change_ids)) { + for (const change_id of Array.from(change_ids)) { ids_map[change_id] = true; } - for (let change of Array.from(this.changes)) { + for (const change of Array.from(this.changes)) { if (ids_map[change.id]) { delete ids_map[change.id]; changes_response.push(change); @@ -159,13 +167,13 @@ const load = function() { if (!(change_to_remove_ids != null ? change_to_remove_ids.length : undefined) > 0) { return; } const i = this.changes.length; const remove_change_id = {}; - for (let change_id of Array.from(change_to_remove_ids)) { + for (const change_id of Array.from(change_to_remove_ids)) { remove_change_id[change_id] = true; } const remaining_changes = []; - for (let change of Array.from(this.changes)) { + for (const change of Array.from(this.changes)) { if (remove_change_id[change.id]) { delete remove_change_id[change.id]; this._markAsDirty(change, "change", "removed"); @@ -179,7 +187,7 @@ const load = function() { validate(text) { let content; - for (let change of Array.from(this.changes)) { + for (const change of Array.from(this.changes)) { if (change.op.i != null) { content = text.slice(change.op.p, change.op.p + change.op.i.length); if (content !== change.op.i) { @@ -187,7 +195,7 @@ const load = function() { } } } - for (let comment of Array.from(this.comments)) { + for (const comment of Array.from(this.comments)) { content = text.slice(comment.op.p, comment.op.p + comment.op.c.length); if (content !== comment.op.c) { throw new Error(`Comment (${JSON.stringify(comment)}) doesn't match text (${JSON.stringify(content)})`); @@ -243,7 +251,7 @@ const load = function() { applyInsertToComments(op) { return (() => { const result = []; - for (let comment of Array.from(this.comments)) { + for (const comment of Array.from(this.comments)) { if (op.p <= comment.op.p) { comment.op.p += op.i.length; result.push(this._markAsDirty(comment, "comment", "moved")); @@ -265,7 +273,7 @@ const load = function() { const op_end = op.p + op_length; return (() => { const result = []; - for (let comment of Array.from(this.comments)) { + for (const comment of Array.from(this.comments)) { const comment_start = comment.op.p; const comment_end = comment.op.p + comment.op.c.length; const comment_length = comment_end - comment_start; @@ -419,7 +427,7 @@ const load = function() { }, metadata: {} }; - for (let key in change.metadata) { const value = change.metadata[key]; after_change.metadata[key] = value; } + for (const key in change.metadata) { const value = change.metadata[key]; after_change.metadata[key] = value; } new_changes.push(after_change); } } @@ -636,7 +644,7 @@ const load = function() { } }); - for (let modification of Array.from(op_modifications)) { + for (const modification of Array.from(op_modifications)) { if (modification.i != null) { content = content.slice(0, modification.p) + modification.i + content.slice(modification.p); } else if (modification.d != null) { @@ -656,7 +664,7 @@ const load = function() { let previous_change = null; const remove_changes = []; const moved_changes = []; - for (let change of Array.from(this.changes)) { + for (const change of Array.from(this.changes)) { if (((previous_change != null ? previous_change.op.i : undefined) != null) && (change.op.i != null)) { const previous_change_end = previous_change.op.p + previous_change.op.i.length; const previous_change_user_id = previous_change.metadata.user_id; @@ -704,7 +712,7 @@ const load = function() { _clone(object) { const clone = {}; - for (let k in object) { const v = object[k]; clone[k] = v; } + for (const k in object) { const v = object[k]; clone[k] = v; } return clone; } }; diff --git a/services/document-updater/app/coffee/RateLimitManager.js b/services/document-updater/app/coffee/RateLimitManager.js index 534fdade92..17803f1316 100644 --- a/services/document-updater/app/coffee/RateLimitManager.js +++ b/services/document-updater/app/coffee/RateLimitManager.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/RealTimeRedisManager.js b/services/document-updater/app/coffee/RealTimeRedisManager.js index b3d7a65680..e2aa12e8d3 100644 --- a/services/document-updater/app/coffee/RealTimeRedisManager.js +++ b/services/document-updater/app/coffee/RealTimeRedisManager.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + no-unused-vars, +*/ +// 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 diff --git a/services/document-updater/app/coffee/RedisManager.js b/services/document-updater/app/coffee/RedisManager.js index f434dfc9d4..80944e10be 100644 --- a/services/document-updater/app/coffee/RedisManager.js +++ b/services/document-updater/app/coffee/RedisManager.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + 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 @@ -299,7 +305,7 @@ module.exports = (RedisManager = { } const jsonOps = appliedOps.map(op => JSON.stringify(op)); - for (let op of Array.from(jsonOps)) { + for (const op of Array.from(jsonOps)) { if (op.indexOf("\u0000") !== -1) { error = new Error("null bytes found in jsonOps"); // this check was added to catch memory corruption in JSON.stringify diff --git a/services/document-updater/app/coffee/ShareJsDB.js b/services/document-updater/app/coffee/ShareJsDB.js index 5b313cee96..20bf42919f 100644 --- a/services/document-updater/app/coffee/ShareJsDB.js +++ b/services/document-updater/app/coffee/ShareJsDB.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + no-unused-vars, +*/ +// 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 diff --git a/services/document-updater/app/coffee/ShareJsUpdateManager.js b/services/document-updater/app/coffee/ShareJsUpdateManager.js index 82eb6923b0..574a5127fa 100644 --- a/services/document-updater/app/coffee/ShareJsUpdateManager.js +++ b/services/document-updater/app/coffee/ShareJsUpdateManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// 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 diff --git a/services/document-updater/app/coffee/SnapshotManager.js b/services/document-updater/app/coffee/SnapshotManager.js index 5f998096af..ca03be85d6 100644 --- a/services/document-updater/app/coffee/SnapshotManager.js +++ b/services/document-updater/app/coffee/SnapshotManager.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + no-return-assign, +*/ +// 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 @@ -38,11 +44,11 @@ module.exports = (SnapshotManager = { } }; - for (let change of Array.from(ranges.changes || [])) { + for (const change of Array.from(ranges.changes || [])) { change.id = SnapshotManager._safeObjectId(change.id); updateMetadata(change.metadata); } - for (let comment of Array.from(ranges.comments || [])) { + for (const comment of Array.from(ranges.comments || [])) { comment.id = SnapshotManager._safeObjectId(comment.id); if ((comment.op != null ? comment.op.t : undefined) != null) { comment.op.t = SnapshotManager._safeObjectId(comment.op.t); diff --git a/services/document-updater/app/coffee/UpdateKeys.js b/services/document-updater/app/coffee/UpdateKeys.js index 470be0ce4a..bcafb807dc 100644 --- a/services/document-updater/app/coffee/UpdateKeys.js +++ b/services/document-updater/app/coffee/UpdateKeys.js @@ -1,3 +1,8 @@ +/* eslint-disable + camelcase, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. module.exports = { combineProjectIdAndDocId(project_id, doc_id) { return `${project_id}:${doc_id}`; }, splitProjectIdAndDocId(project_and_doc_id) { return project_and_doc_id.split(":"); } diff --git a/services/document-updater/app/coffee/UpdateManager.js b/services/document-updater/app/coffee/UpdateManager.js index 5151dfb4e7..de1656a336 100644 --- a/services/document-updater/app/coffee/UpdateManager.js +++ b/services/document-updater/app/coffee/UpdateManager.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + handle-callback-err, + no-unused-vars, +*/ +// 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 @@ -145,7 +152,7 @@ module.exports = (UpdateManager = { }, lockUpdatesAndDo(method, project_id, doc_id, ...rest) { - const adjustedLength = Math.max(rest.length, 1), args = rest.slice(0, adjustedLength - 1), callback = rest[adjustedLength - 1]; + const adjustedLength = Math.max(rest.length, 1); const args = rest.slice(0, adjustedLength - 1); const callback = rest[adjustedLength - 1]; const profile = new Profiler("lockUpdatesAndDo", {project_id, doc_id}); return LockManager.getLock(doc_id, function(error, lockValue) { profile.log("getLock"); @@ -185,7 +192,7 @@ module.exports = (UpdateManager = { // 16-bit character of a blackboard bold character (http://www.fileformat.info/info/unicode/char/1d400/index.htm). // Something must be going on client side that is screwing up the encoding and splitting the // two 16-bit characters so that \uD835 is standalone. - for (let op of Array.from(update.op || [])) { + for (const op of Array.from(update.op || [])) { if (op.i != null) { // Replace high and low surrogate characters with 'replacement character' (\uFFFD) op.i = op.i.replace(/[\uD800-\uDFFF]/g, "\uFFFD"); @@ -215,7 +222,7 @@ module.exports = (UpdateManager = { // changes to it for the next update. return (() => { const result = []; - for (let op of Array.from(update.op)) { + for (const op of Array.from(update.op)) { if (op.i != null) { doc_length += op.i.length; } diff --git a/services/document-updater/app/coffee/mongojs.js b/services/document-updater/app/coffee/mongojs.js index daf6fbed6d..61092e1009 100644 --- a/services/document-updater/app/coffee/mongojs.js +++ b/services/document-updater/app/coffee/mongojs.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/sharejs/count.js b/services/document-updater/app/coffee/sharejs/count.js index ffc3337ac7..c77b76b098 100644 --- a/services/document-updater/app/coffee/sharejs/count.js +++ b/services/document-updater/app/coffee/sharejs/count.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/helpers.js b/services/document-updater/app/coffee/sharejs/helpers.js index 81a561de03..b4500a3214 100644 --- a/services/document-updater/app/coffee/sharejs/helpers.js +++ b/services/document-updater/app/coffee/sharejs/helpers.js @@ -1,3 +1,9 @@ +/* eslint-disable + no-return-assign, + no-unused-vars, +*/ +// 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 @@ -12,7 +18,7 @@ // Add transform and transformX functions for an OT type which has transformComponent defined. // transformComponent(destination array, component, other component, side) let bootstrapTransform; -exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkValidOp, append) { +exports._bt = (bootstrapTransform = function(type, transformComponent, checkValidOp, append) { let transformX; const transformComponentX = function(left, right, destLeft, destRight) { transformComponent(destLeft, left, right, 'left'); @@ -20,7 +26,7 @@ exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkV }; // Transforms rightOp by leftOp. Returns ['rightOp', clientOp'] - type.transformX = (type['transformX'] = (transformX = function(leftOp, rightOp) { + type.transformX = (type.transformX = (transformX = function(leftOp, rightOp) { checkValidOp(leftOp); checkValidOp(rightOp); @@ -47,7 +53,7 @@ exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkV // Recurse. const [l_, r_] = Array.from(transformX(leftOp.slice(k), nextC)); for (l of Array.from(l_)) { append(newLeftOp, l); } - for (let r of Array.from(r_)) { append(newRightOp, r); } + for (const r of Array.from(r_)) { append(newRightOp, r); } rightComponent = null; break; } @@ -61,7 +67,7 @@ exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkV })); // Transforms op with specified type ('left' or 'right') by otherOp. - return type.transform = (type['transform'] = function(op, otherOp, type) { + return type.transform = (type.transform = function(op, otherOp, type) { let _; if ((type !== 'left') && (type !== 'right')) { throw new Error("type must be 'left' or 'right'"); } diff --git a/services/document-updater/app/coffee/sharejs/index.js b/services/document-updater/app/coffee/sharejs/index.js index bf681de7cd..a322063e83 100644 --- a/services/document-updater/app/coffee/sharejs/index.js +++ b/services/document-updater/app/coffee/sharejs/index.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/sharejs/json-api.js b/services/document-updater/app/coffee/sharejs/json-api.js index 1c7c2633ba..67e54f5334 100644 --- a/services/document-updater/app/coffee/sharejs/json-api.js +++ b/services/document-updater/app/coffee/sharejs/json-api.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + no-undef, +*/ +// 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 @@ -32,6 +38,7 @@ class SubDoc { this.doc = doc; this.path = path; } + at(...path) { return this.doc.at(this.path.concat(depath(path))); } get() { return this.doc.getAt(this.path); } // for objects and lists @@ -57,7 +64,7 @@ const traverse = function(snapshot, path) { const container = {data:snapshot}; let key = 'data'; let elem = container; - for (let p of Array.from(path)) { + for (const p of Array.from(path)) { elem = elem[key]; key = p; if (typeof elem === 'undefined') { throw new Error('bad path'); } @@ -155,7 +162,7 @@ json.api = { this.on('change', function(op) { return (() => { const result = []; - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { var i; if ((c.na !== undefined) || (c.si !== undefined) || (c.sd !== undefined)) { // no change to structure @@ -197,7 +204,7 @@ json.api = { var match_path = c.na === undefined ? c.p.slice(0, c.p.length-1) : c.p; result.push((() => { const result1 = []; - for (let {path, event, cb} of Array.from(this._listeners)) { + for (const {path, event, cb} of Array.from(this._listeners)) { var common; if (pathEquals(path, match_path)) { switch (event) { diff --git a/services/document-updater/app/coffee/sharejs/json.js b/services/document-updater/app/coffee/sharejs/json.js index 3e3bee79d9..5619c09be1 100644 --- a/services/document-updater/app/coffee/sharejs/json.js +++ b/services/document-updater/app/coffee/sharejs/json.js @@ -1,3 +1,10 @@ +/* eslint-disable + no-return-assign, + no-undef, + no-useless-catch, +*/ +// 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 @@ -67,7 +74,7 @@ json.apply = function(snapshot, op) { let elem = container; let key = 'data'; - for (let p of Array.from(c.p)) { + for (const p of Array.from(c.p)) { parent = elem; parentkey = key; elem = elem[key]; @@ -187,7 +194,7 @@ json.compose = function(op1, op2) { json.checkValidOp(op2); const newOp = clone(op1); - for (let c of Array.from(op2)) { json.append(newOp, c); } + for (const c of Array.from(op2)) { json.append(newOp, c); } return newOp; }; @@ -197,7 +204,7 @@ json.normalize = function(op) { if (!isArray(op)) { op = [op]; } - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (c.p == null) { c.p = []; } json.append(newOp, c); } @@ -300,7 +307,7 @@ json.transformComponent = function(dest, c, otherC, type) { const res = []; text._tc(res, tc1, tc2, type); - for (let tc of Array.from(res)) { + for (const tc of Array.from(res)) { const jc = { p: c.p.slice(0, common) }; jc.p.push(tc.p); if (tc.i != null) { jc.si = tc.i; } diff --git a/services/document-updater/app/coffee/sharejs/model.js b/services/document-updater/app/coffee/sharejs/model.js index 9b6e65effd..68f68f2e7d 100644 --- a/services/document-updater/app/coffee/sharejs/model.js +++ b/services/document-updater/app/coffee/sharejs/model.js @@ -1,3 +1,10 @@ +/* eslint-disable + no-console, + no-return-assign, + standard/no-callback-literal, +*/ +// 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 @@ -133,7 +140,7 @@ module.exports = (Model = function(db, options) { if (ops.length > 0) { try { // If there's enough ops, it might be worth spinning this out into a webworker thread. - for (let oldOp of Array.from(ops)) { + for (const oldOp of Array.from(ops)) { // Dup detection works by sending the id(s) the op has been submitted with previously. // If the id matches, we reject it. The client can also detect the op has been submitted // already if it sees its own previous id in the ops it sees when it does catchup. @@ -171,7 +178,7 @@ module.exports = (Model = function(db, options) { return callback('Internal error'); } - //newDocData = {snapshot, type:type.name, v:opVersion + 1, meta:docData.meta} + // newDocData = {snapshot, type:type.name, v:opVersion + 1, meta:docData.meta} const writeOp = (db != null ? db.writeOp : undefined) || ((docName, newOpData, callback) => callback()); return writeOp(docName, opData, function(error) { @@ -271,7 +278,7 @@ module.exports = (Model = function(db, options) { if (error) { return (typeof callback === 'function' ? callback(error) : undefined); } let v = start; - for (let op of Array.from(ops)) { op.v = v++; } + for (const op of Array.from(ops)) { op.v = v++; } return (typeof callback === 'function' ? callback(null, ops) : undefined); }); @@ -321,7 +328,7 @@ module.exports = (Model = function(db, options) { console.log(`Catchup ${docName} ${data.v} -> ${data.v + ops.length}`); try { - for (let op of Array.from(ops)) { + for (const op of Array.from(ops)) { data.snapshot = type.apply(data.snapshot, op.op); data.v++; } @@ -620,7 +627,7 @@ module.exports = (Model = function(db, options) { } return (() => { const result = []; - for (let op of Array.from(data)) { + for (const op of Array.from(data)) { var needle; listener(op); @@ -662,7 +669,7 @@ module.exports = (Model = function(db, options) { let pendingWrites = 0; - for (let docName in docs) { + for (const docName in docs) { const doc = docs[docName]; if (doc.committedVersion < doc.v) { pendingWrites++; diff --git a/services/document-updater/app/coffee/sharejs/server/model.js b/services/document-updater/app/coffee/sharejs/server/model.js index 42dd7acc64..485420c040 100644 --- a/services/document-updater/app/coffee/sharejs/server/model.js +++ b/services/document-updater/app/coffee/sharejs/server/model.js @@ -1,3 +1,10 @@ +/* eslint-disable + no-console, + no-return-assign, + standard/no-callback-literal, +*/ +// 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 @@ -133,7 +140,7 @@ module.exports = (Model = function(db, options) { if (ops.length > 0) { try { // If there's enough ops, it might be worth spinning this out into a webworker thread. - for (let oldOp of Array.from(ops)) { + for (const oldOp of Array.from(ops)) { // Dup detection works by sending the id(s) the op has been submitted with previously. // If the id matches, we reject it. The client can also detect the op has been submitted // already if it sees its own previous id in the ops it sees when it does catchup. @@ -175,7 +182,7 @@ module.exports = (Model = function(db, options) { return callback('Internal error'); } - //newDocData = {snapshot, type:type.name, v:opVersion + 1, meta:docData.meta} + // newDocData = {snapshot, type:type.name, v:opVersion + 1, meta:docData.meta} const writeOp = (db != null ? db.writeOp : undefined) || ((docName, newOpData, callback) => callback()); return writeOp(docName, opData, function(error) { @@ -275,7 +282,7 @@ module.exports = (Model = function(db, options) { if (error) { return (typeof callback === 'function' ? callback(error) : undefined); } let v = start; - for (let op of Array.from(ops)) { op.v = v++; } + for (const op of Array.from(ops)) { op.v = v++; } return (typeof callback === 'function' ? callback(null, ops) : undefined); }); @@ -325,7 +332,7 @@ module.exports = (Model = function(db, options) { console.log(`Catchup ${docName} ${data.v} -> ${data.v + ops.length}`); try { - for (let op of Array.from(ops)) { + for (const op of Array.from(ops)) { data.snapshot = type.apply(data.snapshot, op.op); data.v++; } @@ -624,7 +631,7 @@ module.exports = (Model = function(db, options) { } return (() => { const result = []; - for (let op of Array.from(data)) { + for (const op of Array.from(data)) { var needle; listener(op); @@ -666,7 +673,7 @@ module.exports = (Model = function(db, options) { let pendingWrites = 0; - for (let docName in docs) { + for (const docName in docs) { const doc = docs[docName]; if (doc.committedVersion < doc.v) { pendingWrites++; diff --git a/services/document-updater/app/coffee/sharejs/server/syncqueue.js b/services/document-updater/app/coffee/sharejs/server/syncqueue.js index 31b2235ee3..2eecb615e6 100644 --- a/services/document-updater/app/coffee/sharejs/server/syncqueue.js +++ b/services/document-updater/app/coffee/sharejs/server/syncqueue.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/simple.js b/services/document-updater/app/coffee/sharejs/simple.js index 57c4934f73..c0e8e85394 100644 --- a/services/document-updater/app/coffee/sharejs/simple.js +++ b/services/document-updater/app/coffee/sharejs/simple.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns @@ -27,7 +29,7 @@ module.exports = { // // The original snapshot should not be modified. apply(snapshot, op) { - if (!(0 <= op.position && op.position <= snapshot.str.length)) { throw new Error('Invalid position'); } + if (!(op.position >= 0 && op.position <= snapshot.str.length)) { throw new Error('Invalid position'); } let { str diff --git a/services/document-updater/app/coffee/sharejs/syncqueue.js b/services/document-updater/app/coffee/sharejs/syncqueue.js index 31b2235ee3..2eecb615e6 100644 --- a/services/document-updater/app/coffee/sharejs/syncqueue.js +++ b/services/document-updater/app/coffee/sharejs/syncqueue.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/text-api.js b/services/document-updater/app/coffee/sharejs/text-api.js index 295261ff90..7c39b25899 100644 --- a/services/document-updater/app/coffee/sharejs/text-api.js +++ b/services/document-updater/app/coffee/sharejs/text-api.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/text-composable-api.js b/services/document-updater/app/coffee/sharejs/text-composable-api.js index 160ab1c46e..ba6e5f0242 100644 --- a/services/document-updater/app/coffee/sharejs/text-composable-api.js +++ b/services/document-updater/app/coffee/sharejs/text-composable-api.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-undef, +*/ +// 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 @@ -43,7 +48,7 @@ type.api = { let pos = 0; return (() => { const result = []; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { if (typeof component === 'number') { result.push(pos += component); } else if (component.i !== undefined) { diff --git a/services/document-updater/app/coffee/sharejs/text-composable.js b/services/document-updater/app/coffee/sharejs/text-composable.js index 4f43f769cd..79dfb63308 100644 --- a/services/document-updater/app/coffee/sharejs/text-composable.js +++ b/services/document-updater/app/coffee/sharejs/text-composable.js @@ -1,3 +1,11 @@ +/* eslint-disable + no-cond-assign, + no-return-assign, + no-undef, + no-unused-vars, +*/ +// 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 @@ -20,8 +28,8 @@ // Snapshots are strings. let makeAppend; -const p = function() {}; //require('util').debug -const i = function() {}; //require('util').inspect +const p = function() {}; // require('util').debug +const i = function() {}; // require('util').inspect const exports = (typeof WEB !== 'undefined' && WEB !== null) ? {} : module.exports; @@ -36,7 +44,7 @@ const checkOp = function(op) { let last = null; return (() => { const result = []; - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (typeof(c) === 'object') { if (((c.i == null) || !(c.i.length > 0)) && ((c.d == null) || !(c.d.length > 0))) { throw new Error(`Invalid op component: ${i(c)}`); } } else { @@ -55,7 +63,7 @@ const checkOp = function(op) { // Exported for the randomOpGenerator. exports._makeAppend = (makeAppend = op => (function(component) { if ((component === 0) || (component.i === '') || (component.d === '')) { - return; + } else if (op.length === 0) { return op.push(component); } else if ((typeof(component) === 'number') && (typeof(op[op.length - 1]) === 'number')) { @@ -85,7 +93,7 @@ const makeTake = function(op) { const take = function(n, indivisableField) { let c; if (idx === op.length) { return null; } - //assert.notStrictEqual op.length, i, 'The op is too short to traverse the document' + // assert.notStrictEqual op.length, i, 'The op is too short to traverse the document' if (typeof(op[idx]) === 'number') { if ((n == null) || ((op[idx] - offset) <= n)) { @@ -132,7 +140,7 @@ const componentLength = function(component) { exports.normalize = function(op) { const newOp = []; const append = makeAppend(newOp); - for (let component of Array.from(op)) { append(component); } + for (const component of Array.from(op)) { append(component); } return newOp; }; @@ -145,7 +153,7 @@ exports.apply = function(str, op) { const pos = 0; const newDoc = []; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { if (typeof(component) === 'number') { if (component > str.length) { throw new Error('The op is too long for this document'); } newDoc.push(str.slice(0, component)); @@ -158,7 +166,7 @@ exports.apply = function(str, op) { } } - if ('' !== str) { throw new Error("The applied op doesn't traverse the entire document"); } + if (str !== '') { throw new Error("The applied op doesn't traverse the entire document"); } return newDoc.join(''); }; @@ -197,7 +205,7 @@ exports.transform = function(op, otherOp, side) { // Otherwise, skip the inserted text. append(component.i.length); } else { // Delete. - //assert.ok component.d + // assert.ok component.d ({ length } = component.d); @@ -210,7 +218,7 @@ exports.transform = function(op, otherOp, side) { } else if (chunk.i != null) { append(chunk); } else { - //assert.ok chunk.d + // assert.ok chunk.d // The delete is unnecessary now. length -= chunk.d.length; } @@ -302,7 +310,7 @@ exports.invert = function(op) { const result = []; const append = makeAppend(result); - for (let component of Array.from(op)) { append(invertComponent(component)); } + for (const component of Array.from(op)) { append(invertComponent(component)); } return result; }; diff --git a/services/document-updater/app/coffee/sharejs/text-tp2-api.js b/services/document-updater/app/coffee/sharejs/text-tp2-api.js index e3f4f95ea6..97bf606267 100644 --- a/services/document-updater/app/coffee/sharejs/text-tp2-api.js +++ b/services/document-updater/app/coffee/sharejs/text-tp2-api.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-undef, +*/ +// 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 @@ -27,7 +32,7 @@ const appendSkipChars = (op, doc, pos, maxlength) => (() => { return result; })(); -type['api'] = { +type.api = { 'provides': {'text':true}, // The number of characters in the string @@ -81,7 +86,7 @@ type['api'] = { let textPos = 0; const docPos = {index:0, offset:0}; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { var part, remainder; if (typeof component === 'number') { // Skip diff --git a/services/document-updater/app/coffee/sharejs/text-tp2.js b/services/document-updater/app/coffee/sharejs/text-tp2.js index ab123d6ff7..4efcb05871 100644 --- a/services/document-updater/app/coffee/sharejs/text-tp2.js +++ b/services/document-updater/app/coffee/sharejs/text-tp2.js @@ -1,3 +1,11 @@ +/* eslint-disable + no-cond-assign, + no-return-assign, + no-undef, + no-unused-vars, +*/ +// 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 @@ -43,7 +51,7 @@ var type = { const doc = type.create(); doc.data = data; - for (let component of Array.from(data)) { + for (const component of Array.from(data)) { if (typeof component === 'string') { doc.charLength += component.length; doc.totalLength += component.length; @@ -62,7 +70,7 @@ const checkOp = function(op) { let last = null; return (() => { const result = []; - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (typeof(c) === 'object') { if (c.i !== undefined) { if (((typeof(c.i) !== 'string') || !(c.i.length > 0)) && ((typeof(c.i) !== 'number') || !(c.i > 0))) { throw new Error('Inserts must insert a string or a +ive number'); } @@ -147,7 +155,7 @@ type.apply = function(doc, op) { const newDoc = type.create(); const position = {index:0, offset:0}; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { var part, remainder; if (typeof(component) === 'number') { remainder = component; @@ -177,7 +185,7 @@ type.apply = function(doc, op) { // Exported for the randomOpGenerator. type._append = (append = function(op, component) { if ((component === 0) || (component.i === '') || (component.i === 0) || (component.d === 0)) { - return; + } else if (op.length === 0) { return op.push(component); } else { @@ -257,7 +265,7 @@ const componentLength = function(component) { // adjacent inserts and deletes. type.normalize = function(op) { const newOp = []; - for (let component of Array.from(op)) { append(newOp, component); } + for (const component of Array.from(op)) { append(newOp, component); } return newOp; }; diff --git a/services/document-updater/app/coffee/sharejs/text.js b/services/document-updater/app/coffee/sharejs/text.js index 3ecb026c77..3e28b898b6 100644 --- a/services/document-updater/app/coffee/sharejs/text.js +++ b/services/document-updater/app/coffee/sharejs/text.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + no-return-assign, + no-undef, +*/ +// 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 @@ -45,13 +52,13 @@ const checkValidComponent = function(c) { }; const checkValidOp = function(op) { - for (let c of Array.from(op)) { checkValidComponent(c); } + for (const c of Array.from(op)) { checkValidComponent(c); } return true; }; text.apply = function(snapshot, op) { checkValidOp(op); - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { if (component.i != null) { snapshot = strInject(snapshot, component.p, component.i); } else { @@ -92,7 +99,7 @@ text.compose = function(op1, op2) { checkValidOp(op2); const newOp = op1.slice(); - for (let c of Array.from(op2)) { append(newOp, c); } + for (const c of Array.from(op2)) { append(newOp, c); } return newOp; }; @@ -111,7 +118,7 @@ text.normalize = function(op) { // so this is probably the least bad solution. if ((op.i != null) || (op.p != null)) { op = [op]; } - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (c.p == null) { c.p = 0; } append(newOp, c); } @@ -152,7 +159,7 @@ const transformPosition = function(pos, c, insertAfter) { // is pushed after an insert (true) or before it (false). text.transformCursor = function(position, op, side) { const insertAfter = side === 'right'; - for (let c of Array.from(op)) { position = transformPosition(position, c, insertAfter); } + for (const c of Array.from(op)) { position = transformPosition(position, c, insertAfter); } return position; }; diff --git a/services/document-updater/app/coffee/sharejs/types/count.js b/services/document-updater/app/coffee/sharejs/types/count.js index ffc3337ac7..c77b76b098 100644 --- a/services/document-updater/app/coffee/sharejs/types/count.js +++ b/services/document-updater/app/coffee/sharejs/types/count.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/types/helpers.js b/services/document-updater/app/coffee/sharejs/types/helpers.js index 81a561de03..b4500a3214 100644 --- a/services/document-updater/app/coffee/sharejs/types/helpers.js +++ b/services/document-updater/app/coffee/sharejs/types/helpers.js @@ -1,3 +1,9 @@ +/* eslint-disable + no-return-assign, + no-unused-vars, +*/ +// 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 @@ -12,7 +18,7 @@ // Add transform and transformX functions for an OT type which has transformComponent defined. // transformComponent(destination array, component, other component, side) let bootstrapTransform; -exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkValidOp, append) { +exports._bt = (bootstrapTransform = function(type, transformComponent, checkValidOp, append) { let transformX; const transformComponentX = function(left, right, destLeft, destRight) { transformComponent(destLeft, left, right, 'left'); @@ -20,7 +26,7 @@ exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkV }; // Transforms rightOp by leftOp. Returns ['rightOp', clientOp'] - type.transformX = (type['transformX'] = (transformX = function(leftOp, rightOp) { + type.transformX = (type.transformX = (transformX = function(leftOp, rightOp) { checkValidOp(leftOp); checkValidOp(rightOp); @@ -47,7 +53,7 @@ exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkV // Recurse. const [l_, r_] = Array.from(transformX(leftOp.slice(k), nextC)); for (l of Array.from(l_)) { append(newLeftOp, l); } - for (let r of Array.from(r_)) { append(newRightOp, r); } + for (const r of Array.from(r_)) { append(newRightOp, r); } rightComponent = null; break; } @@ -61,7 +67,7 @@ exports['_bt'] = (bootstrapTransform = function(type, transformComponent, checkV })); // Transforms op with specified type ('left' or 'right') by otherOp. - return type.transform = (type['transform'] = function(op, otherOp, type) { + return type.transform = (type.transform = function(op, otherOp, type) { let _; if ((type !== 'left') && (type !== 'right')) { throw new Error("type must be 'left' or 'right'"); } diff --git a/services/document-updater/app/coffee/sharejs/types/index.js b/services/document-updater/app/coffee/sharejs/types/index.js index bf681de7cd..a322063e83 100644 --- a/services/document-updater/app/coffee/sharejs/types/index.js +++ b/services/document-updater/app/coffee/sharejs/types/index.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns diff --git a/services/document-updater/app/coffee/sharejs/types/json-api.js b/services/document-updater/app/coffee/sharejs/types/json-api.js index 1c7c2633ba..67e54f5334 100644 --- a/services/document-updater/app/coffee/sharejs/types/json-api.js +++ b/services/document-updater/app/coffee/sharejs/types/json-api.js @@ -1,3 +1,9 @@ +/* eslint-disable + camelcase, + no-undef, +*/ +// 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 @@ -32,6 +38,7 @@ class SubDoc { this.doc = doc; this.path = path; } + at(...path) { return this.doc.at(this.path.concat(depath(path))); } get() { return this.doc.getAt(this.path); } // for objects and lists @@ -57,7 +64,7 @@ const traverse = function(snapshot, path) { const container = {data:snapshot}; let key = 'data'; let elem = container; - for (let p of Array.from(path)) { + for (const p of Array.from(path)) { elem = elem[key]; key = p; if (typeof elem === 'undefined') { throw new Error('bad path'); } @@ -155,7 +162,7 @@ json.api = { this.on('change', function(op) { return (() => { const result = []; - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { var i; if ((c.na !== undefined) || (c.si !== undefined) || (c.sd !== undefined)) { // no change to structure @@ -197,7 +204,7 @@ json.api = { var match_path = c.na === undefined ? c.p.slice(0, c.p.length-1) : c.p; result.push((() => { const result1 = []; - for (let {path, event, cb} of Array.from(this._listeners)) { + for (const {path, event, cb} of Array.from(this._listeners)) { var common; if (pathEquals(path, match_path)) { switch (event) { diff --git a/services/document-updater/app/coffee/sharejs/types/json.js b/services/document-updater/app/coffee/sharejs/types/json.js index 3e3bee79d9..5619c09be1 100644 --- a/services/document-updater/app/coffee/sharejs/types/json.js +++ b/services/document-updater/app/coffee/sharejs/types/json.js @@ -1,3 +1,10 @@ +/* eslint-disable + no-return-assign, + no-undef, + no-useless-catch, +*/ +// 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 @@ -67,7 +74,7 @@ json.apply = function(snapshot, op) { let elem = container; let key = 'data'; - for (let p of Array.from(c.p)) { + for (const p of Array.from(c.p)) { parent = elem; parentkey = key; elem = elem[key]; @@ -187,7 +194,7 @@ json.compose = function(op1, op2) { json.checkValidOp(op2); const newOp = clone(op1); - for (let c of Array.from(op2)) { json.append(newOp, c); } + for (const c of Array.from(op2)) { json.append(newOp, c); } return newOp; }; @@ -197,7 +204,7 @@ json.normalize = function(op) { if (!isArray(op)) { op = [op]; } - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (c.p == null) { c.p = []; } json.append(newOp, c); } @@ -300,7 +307,7 @@ json.transformComponent = function(dest, c, otherC, type) { const res = []; text._tc(res, tc1, tc2, type); - for (let tc of Array.from(res)) { + for (const tc of Array.from(res)) { const jc = { p: c.p.slice(0, common) }; jc.p.push(tc.p); if (tc.i != null) { jc.si = tc.i; } diff --git a/services/document-updater/app/coffee/sharejs/types/model.js b/services/document-updater/app/coffee/sharejs/types/model.js index 9b6e65effd..68f68f2e7d 100644 --- a/services/document-updater/app/coffee/sharejs/types/model.js +++ b/services/document-updater/app/coffee/sharejs/types/model.js @@ -1,3 +1,10 @@ +/* eslint-disable + no-console, + no-return-assign, + standard/no-callback-literal, +*/ +// 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 @@ -133,7 +140,7 @@ module.exports = (Model = function(db, options) { if (ops.length > 0) { try { // If there's enough ops, it might be worth spinning this out into a webworker thread. - for (let oldOp of Array.from(ops)) { + for (const oldOp of Array.from(ops)) { // Dup detection works by sending the id(s) the op has been submitted with previously. // If the id matches, we reject it. The client can also detect the op has been submitted // already if it sees its own previous id in the ops it sees when it does catchup. @@ -171,7 +178,7 @@ module.exports = (Model = function(db, options) { return callback('Internal error'); } - //newDocData = {snapshot, type:type.name, v:opVersion + 1, meta:docData.meta} + // newDocData = {snapshot, type:type.name, v:opVersion + 1, meta:docData.meta} const writeOp = (db != null ? db.writeOp : undefined) || ((docName, newOpData, callback) => callback()); return writeOp(docName, opData, function(error) { @@ -271,7 +278,7 @@ module.exports = (Model = function(db, options) { if (error) { return (typeof callback === 'function' ? callback(error) : undefined); } let v = start; - for (let op of Array.from(ops)) { op.v = v++; } + for (const op of Array.from(ops)) { op.v = v++; } return (typeof callback === 'function' ? callback(null, ops) : undefined); }); @@ -321,7 +328,7 @@ module.exports = (Model = function(db, options) { console.log(`Catchup ${docName} ${data.v} -> ${data.v + ops.length}`); try { - for (let op of Array.from(ops)) { + for (const op of Array.from(ops)) { data.snapshot = type.apply(data.snapshot, op.op); data.v++; } @@ -620,7 +627,7 @@ module.exports = (Model = function(db, options) { } return (() => { const result = []; - for (let op of Array.from(data)) { + for (const op of Array.from(data)) { var needle; listener(op); @@ -662,7 +669,7 @@ module.exports = (Model = function(db, options) { let pendingWrites = 0; - for (let docName in docs) { + for (const docName in docs) { const doc = docs[docName]; if (doc.committedVersion < doc.v) { pendingWrites++; diff --git a/services/document-updater/app/coffee/sharejs/types/simple.js b/services/document-updater/app/coffee/sharejs/types/simple.js index 57c4934f73..c0e8e85394 100644 --- a/services/document-updater/app/coffee/sharejs/types/simple.js +++ b/services/document-updater/app/coffee/sharejs/types/simple.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns @@ -27,7 +29,7 @@ module.exports = { // // The original snapshot should not be modified. apply(snapshot, op) { - if (!(0 <= op.position && op.position <= snapshot.str.length)) { throw new Error('Invalid position'); } + if (!(op.position >= 0 && op.position <= snapshot.str.length)) { throw new Error('Invalid position'); } let { str diff --git a/services/document-updater/app/coffee/sharejs/types/syncqueue.js b/services/document-updater/app/coffee/sharejs/types/syncqueue.js index 31b2235ee3..2eecb615e6 100644 --- a/services/document-updater/app/coffee/sharejs/types/syncqueue.js +++ b/services/document-updater/app/coffee/sharejs/types/syncqueue.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/types/text-api.js b/services/document-updater/app/coffee/sharejs/types/text-api.js index 295261ff90..7c39b25899 100644 --- a/services/document-updater/app/coffee/sharejs/types/text-api.js +++ b/services/document-updater/app/coffee/sharejs/types/text-api.js @@ -1,3 +1,5 @@ +// TODO: This file was created by bulk-decaffeinate. +// Sanity-check the conversion and remove this comment. /* * decaffeinate suggestions: * DS101: Remove unnecessary use of Array.from diff --git a/services/document-updater/app/coffee/sharejs/types/text-composable-api.js b/services/document-updater/app/coffee/sharejs/types/text-composable-api.js index 160ab1c46e..ba6e5f0242 100644 --- a/services/document-updater/app/coffee/sharejs/types/text-composable-api.js +++ b/services/document-updater/app/coffee/sharejs/types/text-composable-api.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-undef, +*/ +// 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 @@ -43,7 +48,7 @@ type.api = { let pos = 0; return (() => { const result = []; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { if (typeof component === 'number') { result.push(pos += component); } else if (component.i !== undefined) { diff --git a/services/document-updater/app/coffee/sharejs/types/text-composable.js b/services/document-updater/app/coffee/sharejs/types/text-composable.js index 4f43f769cd..79dfb63308 100644 --- a/services/document-updater/app/coffee/sharejs/types/text-composable.js +++ b/services/document-updater/app/coffee/sharejs/types/text-composable.js @@ -1,3 +1,11 @@ +/* eslint-disable + no-cond-assign, + no-return-assign, + no-undef, + no-unused-vars, +*/ +// 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 @@ -20,8 +28,8 @@ // Snapshots are strings. let makeAppend; -const p = function() {}; //require('util').debug -const i = function() {}; //require('util').inspect +const p = function() {}; // require('util').debug +const i = function() {}; // require('util').inspect const exports = (typeof WEB !== 'undefined' && WEB !== null) ? {} : module.exports; @@ -36,7 +44,7 @@ const checkOp = function(op) { let last = null; return (() => { const result = []; - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (typeof(c) === 'object') { if (((c.i == null) || !(c.i.length > 0)) && ((c.d == null) || !(c.d.length > 0))) { throw new Error(`Invalid op component: ${i(c)}`); } } else { @@ -55,7 +63,7 @@ const checkOp = function(op) { // Exported for the randomOpGenerator. exports._makeAppend = (makeAppend = op => (function(component) { if ((component === 0) || (component.i === '') || (component.d === '')) { - return; + } else if (op.length === 0) { return op.push(component); } else if ((typeof(component) === 'number') && (typeof(op[op.length - 1]) === 'number')) { @@ -85,7 +93,7 @@ const makeTake = function(op) { const take = function(n, indivisableField) { let c; if (idx === op.length) { return null; } - //assert.notStrictEqual op.length, i, 'The op is too short to traverse the document' + // assert.notStrictEqual op.length, i, 'The op is too short to traverse the document' if (typeof(op[idx]) === 'number') { if ((n == null) || ((op[idx] - offset) <= n)) { @@ -132,7 +140,7 @@ const componentLength = function(component) { exports.normalize = function(op) { const newOp = []; const append = makeAppend(newOp); - for (let component of Array.from(op)) { append(component); } + for (const component of Array.from(op)) { append(component); } return newOp; }; @@ -145,7 +153,7 @@ exports.apply = function(str, op) { const pos = 0; const newDoc = []; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { if (typeof(component) === 'number') { if (component > str.length) { throw new Error('The op is too long for this document'); } newDoc.push(str.slice(0, component)); @@ -158,7 +166,7 @@ exports.apply = function(str, op) { } } - if ('' !== str) { throw new Error("The applied op doesn't traverse the entire document"); } + if (str !== '') { throw new Error("The applied op doesn't traverse the entire document"); } return newDoc.join(''); }; @@ -197,7 +205,7 @@ exports.transform = function(op, otherOp, side) { // Otherwise, skip the inserted text. append(component.i.length); } else { // Delete. - //assert.ok component.d + // assert.ok component.d ({ length } = component.d); @@ -210,7 +218,7 @@ exports.transform = function(op, otherOp, side) { } else if (chunk.i != null) { append(chunk); } else { - //assert.ok chunk.d + // assert.ok chunk.d // The delete is unnecessary now. length -= chunk.d.length; } @@ -302,7 +310,7 @@ exports.invert = function(op) { const result = []; const append = makeAppend(result); - for (let component of Array.from(op)) { append(invertComponent(component)); } + for (const component of Array.from(op)) { append(invertComponent(component)); } return result; }; diff --git a/services/document-updater/app/coffee/sharejs/types/text-tp2-api.js b/services/document-updater/app/coffee/sharejs/types/text-tp2-api.js index e3f4f95ea6..97bf606267 100644 --- a/services/document-updater/app/coffee/sharejs/types/text-tp2-api.js +++ b/services/document-updater/app/coffee/sharejs/types/text-tp2-api.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-undef, +*/ +// 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 @@ -27,7 +32,7 @@ const appendSkipChars = (op, doc, pos, maxlength) => (() => { return result; })(); -type['api'] = { +type.api = { 'provides': {'text':true}, // The number of characters in the string @@ -81,7 +86,7 @@ type['api'] = { let textPos = 0; const docPos = {index:0, offset:0}; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { var part, remainder; if (typeof component === 'number') { // Skip diff --git a/services/document-updater/app/coffee/sharejs/types/text-tp2.js b/services/document-updater/app/coffee/sharejs/types/text-tp2.js index ab123d6ff7..4efcb05871 100644 --- a/services/document-updater/app/coffee/sharejs/types/text-tp2.js +++ b/services/document-updater/app/coffee/sharejs/types/text-tp2.js @@ -1,3 +1,11 @@ +/* eslint-disable + no-cond-assign, + no-return-assign, + no-undef, + no-unused-vars, +*/ +// 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 @@ -43,7 +51,7 @@ var type = { const doc = type.create(); doc.data = data; - for (let component of Array.from(data)) { + for (const component of Array.from(data)) { if (typeof component === 'string') { doc.charLength += component.length; doc.totalLength += component.length; @@ -62,7 +70,7 @@ const checkOp = function(op) { let last = null; return (() => { const result = []; - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (typeof(c) === 'object') { if (c.i !== undefined) { if (((typeof(c.i) !== 'string') || !(c.i.length > 0)) && ((typeof(c.i) !== 'number') || !(c.i > 0))) { throw new Error('Inserts must insert a string or a +ive number'); } @@ -147,7 +155,7 @@ type.apply = function(doc, op) { const newDoc = type.create(); const position = {index:0, offset:0}; - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { var part, remainder; if (typeof(component) === 'number') { remainder = component; @@ -177,7 +185,7 @@ type.apply = function(doc, op) { // Exported for the randomOpGenerator. type._append = (append = function(op, component) { if ((component === 0) || (component.i === '') || (component.i === 0) || (component.d === 0)) { - return; + } else if (op.length === 0) { return op.push(component); } else { @@ -257,7 +265,7 @@ const componentLength = function(component) { // adjacent inserts and deletes. type.normalize = function(op) { const newOp = []; - for (let component of Array.from(op)) { append(newOp, component); } + for (const component of Array.from(op)) { append(newOp, component); } return newOp; }; diff --git a/services/document-updater/app/coffee/sharejs/types/text.js b/services/document-updater/app/coffee/sharejs/types/text.js index fed546d10f..66aee0f7d7 100644 --- a/services/document-updater/app/coffee/sharejs/types/text.js +++ b/services/document-updater/app/coffee/sharejs/types/text.js @@ -1,3 +1,10 @@ +/* eslint-disable + camelcase, + no-return-assign, + no-undef, +*/ +// 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 @@ -46,13 +53,13 @@ const checkValidComponent = function(c) { }; const checkValidOp = function(op) { - for (let c of Array.from(op)) { checkValidComponent(c); } + for (const c of Array.from(op)) { checkValidComponent(c); } return true; }; text.apply = function(snapshot, op) { checkValidOp(op); - for (let component of Array.from(op)) { + for (const component of Array.from(op)) { if (component.i != null) { snapshot = strInject(snapshot, component.p, component.i); } else if (component.d != null) { @@ -97,7 +104,7 @@ text.compose = function(op1, op2) { checkValidOp(op2); const newOp = op1.slice(); - for (let c of Array.from(op2)) { append(newOp, c); } + for (const c of Array.from(op2)) { append(newOp, c); } return newOp; }; @@ -116,7 +123,7 @@ text.normalize = function(op) { // so this is probably the least bad solution. if ((op.i != null) || (op.p != null)) { op = [op]; } - for (let c of Array.from(op)) { + for (const c of Array.from(op)) { if (c.p == null) { c.p = 0; } append(newOp, c); } @@ -161,7 +168,7 @@ const transformPosition = function(pos, c, insertAfter) { // is pushed after an insert (true) or before it (false). text.transformCursor = function(position, op, side) { const insertAfter = side === 'right'; - for (let c of Array.from(op)) { position = transformPosition(position, c, insertAfter); } + for (const c of Array.from(op)) { position = transformPosition(position, c, insertAfter); } return position; }; diff --git a/services/document-updater/app/coffee/sharejs/types/web-prelude.js b/services/document-updater/app/coffee/sharejs/types/web-prelude.js index b7252728e9..e6a7529a52 100644 --- a/services/document-updater/app/coffee/sharejs/types/web-prelude.js +++ b/services/document-updater/app/coffee/sharejs/types/web-prelude.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. // This is included at the top of each compiled type file for the web. /** @@ -7,5 +12,5 @@ const WEB = true; -const exports = window['sharejs']; +const exports = window.sharejs; diff --git a/services/document-updater/app/coffee/sharejs/web-prelude.js b/services/document-updater/app/coffee/sharejs/web-prelude.js index b7252728e9..e6a7529a52 100644 --- a/services/document-updater/app/coffee/sharejs/web-prelude.js +++ b/services/document-updater/app/coffee/sharejs/web-prelude.js @@ -1,3 +1,8 @@ +/* eslint-disable + no-unused-vars, +*/ +// TODO: This file was created by bulk-decaffeinate. +// Fix any style issues and re-enable lint. // This is included at the top of each compiled type file for the web. /** @@ -7,5 +12,5 @@ const WEB = true; -const exports = window['sharejs']; +const exports = window.sharejs;