@@ -165,15 +165,15 @@ module.exports = function (sequelize, DataTypes) {
165165 }
166166 Note . encodeNoteId = function ( id ) {
167167 // remove dashes in UUID and encode in url-safe base64
168- let str = id . replace ( / - / g, '' )
169- let hexStr = Buffer . from ( str , 'hex' )
168+ const str = id . replace ( / - / g, '' )
169+ const hexStr = Buffer . from ( str , 'hex' )
170170 return base64url . encode ( hexStr )
171171 }
172172 Note . decodeNoteId = function ( encodedId ) {
173173 // decode from url-safe base64
174- let id = base64url . toBuffer ( encodedId ) . toString ( 'hex' )
174+ const id = base64url . toBuffer ( encodedId ) . toString ( 'hex' )
175175 // add dashes between the UUID string parts
176- let idParts = [ ]
176+ const idParts = [ ]
177177 idParts . push ( id . substr ( 0 , 8 ) )
178178 idParts . push ( id . substr ( 8 , 4 ) )
179179 idParts . push ( id . substr ( 12 , 4 ) )
@@ -196,7 +196,7 @@ module.exports = function (sequelize, DataTypes) {
196196 }
197197 } ) . then ( function ( note ) {
198198 if ( note ) {
199- let filePath = path . join ( config . docsPath , noteId + '.md' )
199+ const filePath = path . join ( config . docsPath , noteId + '.md' )
200200 if ( Note . checkFileExist ( filePath ) ) {
201201 // if doc in filesystem have newer modified time than last change time
202202 // then will update the doc in db
@@ -421,20 +421,20 @@ module.exports = function (sequelize, DataTypes) {
421421 if ( ot . TextOperation . isRetain ( op ) ) {
422422 index += op
423423 } else if ( ot . TextOperation . isInsert ( op ) ) {
424- let opStart = index
425- let opEnd = index + op . length
426- var inserted = false
424+ const opStart = index
425+ const opEnd = index + op . length
426+ let inserted = false
427427 // authorship format: [userId, startPos, endPos, createdAt, updatedAt]
428428 if ( authorships . length <= 0 ) authorships . push ( [ userId , opStart , opEnd , timestamp , timestamp ] )
429429 else {
430430 for ( let j = 0 ; j < authorships . length ; j ++ ) {
431- let authorship = authorships [ j ]
431+ const authorship = authorships [ j ]
432432 if ( ! inserted ) {
433- let nextAuthorship = authorships [ j + 1 ] || - 1
433+ const nextAuthorship = authorships [ j + 1 ] || - 1
434434 if ( ( nextAuthorship !== - 1 && nextAuthorship [ 1 ] >= opEnd ) || j >= authorships . length - 1 ) {
435435 if ( authorship [ 1 ] < opStart && authorship [ 2 ] > opStart ) {
436436 // divide
437- let postLength = authorship [ 2 ] - opStart
437+ const postLength = authorship [ 2 ] - opStart
438438 authorship [ 2 ] = opStart
439439 authorship [ 4 ] = timestamp
440440 authorships . splice ( j + 1 , 0 , [ userId , opStart , opEnd , timestamp , timestamp ] )
@@ -460,13 +460,13 @@ module.exports = function (sequelize, DataTypes) {
460460 }
461461 index += op . length
462462 } else if ( ot . TextOperation . isDelete ( op ) ) {
463- let opStart = index
464- let opEnd = index - op
463+ const opStart = index
464+ const opEnd = index - op
465465 if ( operation . length === 1 ) {
466466 authorships = [ ]
467467 } else if ( authorships . length > 0 ) {
468468 for ( let j = 0 ; j < authorships . length ; j ++ ) {
469- let authorship = authorships [ j ]
469+ const authorship = authorships [ j ]
470470 if ( authorship [ 1 ] >= opStart && authorship [ 1 ] <= opEnd && authorship [ 2 ] >= opStart && authorship [ 2 ] <= opEnd ) {
471471 authorships . splice ( j , 1 )
472472 j -= 1
@@ -491,12 +491,12 @@ module.exports = function (sequelize, DataTypes) {
491491 }
492492 // merge
493493 for ( let j = 0 ; j < authorships . length ; j ++ ) {
494- let authorship = authorships [ j ]
494+ const authorship = authorships [ j ]
495495 for ( let k = j + 1 ; k < authorships . length ; k ++ ) {
496- let nextAuthorship = authorships [ k ]
496+ const nextAuthorship = authorships [ k ]
497497 if ( nextAuthorship && authorship [ 0 ] === nextAuthorship [ 0 ] && authorship [ 2 ] === nextAuthorship [ 1 ] ) {
498- let minTimestamp = Math . min ( authorship [ 3 ] , nextAuthorship [ 3 ] )
499- let maxTimestamp = Math . max ( authorship [ 3 ] , nextAuthorship [ 3 ] )
498+ const minTimestamp = Math . min ( authorship [ 3 ] , nextAuthorship [ 3 ] )
499+ const maxTimestamp = Math . max ( authorship [ 3 ] , nextAuthorship [ 3 ] )
500500 authorships . splice ( j , 1 , [ authorship [ 0 ] , authorship [ 1 ] , nextAuthorship [ 2 ] , minTimestamp , maxTimestamp ] )
501501 authorships . splice ( k , 1 )
502502 j -= 1
@@ -506,7 +506,7 @@ module.exports = function (sequelize, DataTypes) {
506506 }
507507 // clear
508508 for ( let j = 0 ; j < authorships . length ; j ++ ) {
509- let authorship = authorships [ j ]
509+ const authorship = authorships [ j ]
510510 if ( ! authorship [ 0 ] ) {
511511 authorships . splice ( j , 1 )
512512 j -= 1
@@ -537,11 +537,11 @@ module.exports = function (sequelize, DataTypes) {
537537 var lengthBias = 0
538538 for ( let j = 0 ; j < patch . length ; j ++ ) {
539539 var operation = [ ]
540- let p = patch [ j ]
540+ const p = patch [ j ]
541541 var currIndex = p . start1
542542 var currLength = contentLength - bias
543543 for ( let i = 0 ; i < p . diffs . length ; i ++ ) {
544- let diff = p . diffs [ i ]
544+ const diff = p . diffs [ i ]
545545 switch ( diff [ 0 ] ) {
546546 case 0 : // retain
547547 if ( i === 0 ) {
0 commit comments