refactor: fix lint on lib/workers/dmpWorker.js

Signed-off-by: BoHong Li <raccoon@hackmd.io>
This commit is contained in:
BoHong Li 2019-08-02 01:01:02 +08:00
parent ee1538eed9
commit e2a13b05b1
No known key found for this signature in database
GPG Key ID: 06770355DC9ECD38
1 changed files with 6 additions and 6 deletions

View File

@ -13,7 +13,7 @@ process.on('message', function (data) {
}
switch (data.msg) {
case 'create patch':
if (!data.hasOwnProperty('lastDoc') || !data.hasOwnProperty('currDoc')) {
if (!Object.hasOwnProperty.call(data, 'lastDoc') || !Object.hasOwnProperty.call(data, 'currDoc')) {
return logger.error('dmp worker error: not enough data on create patch')
}
try {
@ -33,7 +33,7 @@ process.on('message', function (data) {
}
break
case 'get revision':
if (!data.hasOwnProperty('revisions') || !data.hasOwnProperty('count')) {
if (!Object.hasOwnProperty.call(data, 'revisions') || !Object.hasOwnProperty.call(data, 'count')) {
return logger.error('dmp worker error: not enough data on get revision')
}
try {
@ -77,12 +77,12 @@ function getRevision (revisions, count) {
if (count <= Math.round(revisions.length / 2)) {
// start from top to target
for (let i = 0; i < count; i++) {
let revision = revisions[i]
const revision = revisions[i]
if (i === 0) {
startContent = revision.content || revision.lastContent
}
if (i !== count - 1) {
let patch = dmp.patch_fromText(revision.patch)
const patch = dmp.patch_fromText(revision.patch)
applyPatches = applyPatches.concat(patch)
}
lastPatch = revision.patch
@ -99,13 +99,13 @@ function getRevision (revisions, count) {
// start from bottom to target
var l = revisions.length - 1
for (var i = l; i >= count - 1; i--) {
let revision = revisions[i]
const revision = revisions[i]
if (i === l) {
startContent = revision.lastContent
authorship = revision.authorship
}
if (revision.patch) {
let patch = dmp.patch_fromText(revision.patch)
const patch = dmp.patch_fromText(revision.patch)
applyPatches = applyPatches.concat(patch)
}
lastPatch = revision.patch