decaffeinate: Run post-processing cleanups on DeleteQueueManager.coffee and 58 other files
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Sanity-check the conversion and remove this comment.
|
||||
module.exports = require("metrics-sharelatex");
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(":"); }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'"); }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'"); }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user