@@ -140,7 +140,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
140140 return ;
141141 }
142142 db . backup ( _backupFileName , {
143- progress ( { totalPages : t , remainingPages : r } ) {
143+ progress ( { totalPages : t , remainingPages : r } ) {
144144 const _progress = ( ( t - r ) / t * 100 ) . toFixed ( 1 ) ;
145145 debug ( 'database backup progress: %s%' , _progress ) ;
146146 eventEmitter . emit ( 'backup:progress' , trigger , _backupFileName , _progress ) ;
@@ -292,13 +292,13 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
292292 _getLastPatchInfo . push ( _generateGetLastPatchInfoQuery ( 'pending_patches' ) ) ;
293293 _getPatchFromColumn . push ( _generateGetPatchFromPendingTableQuery ( ) ) ;
294294 // Get all tables ending with _patches except pending_patches
295- const _patchTables = db . prepare ( ` SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%_patches' AND name != 'pending_patches'` ) . all ( ) ;
295+ const _patchTables = db . prepare ( " SELECT name FROM sqlite_master WHERE type='table' AND name LIKE '%_patches' AND name != 'pending_patches'" ) . all ( ) ;
296296 // Generate merge patches query plan for each table
297297 for ( const table of _patchTables ) {
298298 const _tableName = table . name . slice ( 0 , - 8 ) ; // Remove '_patches' suffix
299299 try {
300300 // Check if index exists on _patchedAt column
301- const _indexExists = db . prepare ( ` SELECT 1 FROM sqlite_master WHERE type='index' AND tbl_name=? AND sql LIKE '%_patchedAt%'` ) . get ( [ table . name ] ) ;
301+ const _indexExists = db . prepare ( " SELECT 1 FROM sqlite_master WHERE type='index' AND tbl_name=? AND sql LIKE '%_patchedAt%'" ) . get ( [ table . name ] ) ;
302302 if ( ! _indexExists ) {
303303 console . warn ( `Warning: Table ${ table . name } is missing an index on _patchedAt column which may impact performance` ) ;
304304 }
@@ -379,7 +379,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
379379 *
380380 * This function applies migration scripts (up or down) as needed to synchronize the database schema to the target version
381381 * as determined by the length of the `appMigrations` array. If the target version is less than the current database version,
382- * down migrations are executed in reverse order. If the target version is greater than the current version, up migrations are
382+ * down migrations are executed in reverse order. If the target version is greater than the current version, up migrations are
383383 * applied in order. Migration changes are transactional.
384384 *
385385 * @param {Array<{ up: string, down: string }> } appMigrations Array of migration objects describing the changes required for each version.
@@ -439,8 +439,8 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
439439 * Detects missing patches since a given timestamp.
440440 *
441441 * This function analyzes the database for missing sequence IDs from a provided timestamp onward.
442- * For each peer that has missing patches, it optionally updates that peer's statistics and
443- * sends a retransmission request for the missing sequence range to the peer, provided a socket
442+ * For each peer that has missing patches, it optionally updates that peer's statistics and
443+ * sends a retransmission request for the missing sequence range to the peer, provided a socket
444444 * connection exists. Updates statistics for synchronized peers as well.
445445 *
446446 * TODO: Add test for case where peerSockets[peerId] does not exist but peerId exists in DB with missing patches.
@@ -530,7 +530,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
530530 * @param {Object } rowPatch - The row data to use as the delta for the generated patch.
531531 * @param {function(Error|null, string=):void } [callback] - Optional callback invoked with error or the session token.
532532 */
533- function upsert ( tableName , rowPatch , callback ) {
533+ function upsert ( tableName , rowPatch , callback ) {
534534 if ( ! dbVersion ) {
535535 return callback ( new Error ( 'Database version is not set' ) ) ;
536536 }
@@ -612,9 +612,9 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
612612 /**
613613 * Handles patches received from connected peers.
614614 *
615- * This function processes an incoming patch message from a remote peer.
616- * It ignores self-generated patches, handles version mismatches by storing
617- * incompatible patches in the pending_patches table, and applies valid patches
615+ * This function processes an incoming patch message from a remote peer.
616+ * It ignores self-generated patches, handles version mismatches by storing
617+ * incompatible patches in the pending_patches table, and applies valid patches
618618 * to the relevant table. Patch application is debounced to batch updates.
619619 *
620620 * @param {Object } patch - The patch object received from a remote peer.
@@ -623,7 +623,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
623623 * @param {string } patch.tab - The table name to which the patch applies.
624624 * @param {number } patch.at - The timestamp when the patch was created.
625625 */
626- function _onPatchReceivedFromPeers ( patch ) {
626+ function _onPatchReceivedFromPeers ( patch ) {
627627 try {
628628 if ( parseInt ( patch . peer , 10 ) === myPeerId ) {
629629 debug ( 'Received patch from myself. Ignore it.' ) ;
@@ -820,7 +820,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
820820 _peerStat [ LAST_SEQUENCE_ID ] = msg . seq ;
821821 _peerStat [ LAST_PATCH_AT_TIMESTAMP ] = msg . at ;
822822 }
823- // Otherwise, it's an old packet, or a ping (same sequence), if so do nothing.
823+ // Otherwise, it's an old packet, or a ping (same sequence), if so do nothing.
824824 // (Sequences can never go backward. If we receive a packet with a sequence less than the guaranteed one, we can ignore it—a double resend.)
825825 }
826826
@@ -918,7 +918,7 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
918918 * TODO: Return an error if the request is too old (patch table has been cleaned up)?
919919 */
920920 function _onRequestForMissingPatchFromPeers ( msg ) {
921- let _missingPatch = [ ] ;
921+ let _missingPatch ;
922922 try {
923923 _missingPatch = globalStatements . getPatchFromColumn ( msg . peer , msg . minSeq , msg . maxSeq ) ;
924924 }
@@ -1012,9 +1012,9 @@ const SQLiteOnSteroid = (db, myPeerId = null, options) => {
10121012 /**
10131013 * Handles synchronization status update for a peer.
10141014 *
1015- * This function is called when a peer is considered synced, i.e., when it has received
1015+ * This function is called when a peer is considered synced, i.e., when it has received
10161016 * the last contiguous sequence for that peer. When a peer becomes synced
1017- * for the first time, it is removed from the `peerStartedNotSynced` set and
1017+ * for the first time, it is removed from the `peerStartedNotSynced` set and
10181018 * the 'synced' event is emitted for that peer.
10191019 *
10201020 * @param {number|string } peerId - ID of the peer that is now synced. May be a string if from a for-in loop.
0 commit comments