Skip to content

Commit

Permalink
chore: use the same noop everywhere (#511)
Browse files Browse the repository at this point in the history
This minor cleanup uses the same `noop` utility function across the
codebase, rather than defining them as one-offs.

Co-authored-by: Gregor MacLennan <gmaclennan@digital-democracy.org>
  • Loading branch information
EvanHahn and gmaclennan authored Mar 25, 2024
1 parent 97c1699 commit b321922
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/datatype/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { validate } from '@mapeo/schema'
import { getTableConfig } from 'drizzle-orm/sqlite-core'
import { eq, inArray, placeholder } from 'drizzle-orm'
import { randomBytes } from 'node:crypto'
import { deNullify } from '../utils.js'
import { noop, deNullify } from '../utils.js'
import crypto from 'hypercore-crypto'
import { TypedEmitter } from 'tiny-typed-emitter'

Expand Down Expand Up @@ -291,5 +291,3 @@ export class DataType extends TypedEmitter {
this.emit('updated-docs', updatedDocs)
}
}

function noop() {}
3 changes: 1 addition & 2 deletions src/discovery/local-discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { TypedEmitter } from 'tiny-typed-emitter'
import net from 'node:net'
import NoiseSecretStream from '@hyperswarm/secret-stream'
import { once } from 'node:events'
import { noop } from '../utils.js'
import { DnsSd } from './dns-sd.js'
import { isPrivate } from 'bogon'
import StartStopStateMachine from 'start-stop-state-machine'
Expand Down Expand Up @@ -299,5 +300,3 @@ function getAddress(server) {
}
return addr
}

function noop() {}
4 changes: 1 addition & 3 deletions src/local-peers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check
import { TypedEmitter } from 'tiny-typed-emitter'
import Protomux from 'protomux'
import { assert, ExhaustivenessError, keyToId } from './utils.js'
import { assert, ExhaustivenessError, keyToId, noop } from './utils.js'
import { isBlank } from './lib/string.js'
import cenc from 'compact-encoding'
import {
Expand Down Expand Up @@ -626,8 +626,6 @@ function parseProjectJoinDetails(data) {
return result
}

function noop() {}

/**
* We can temporarily have more than 1 peer for a device while connections are
* deduplicating. We don't expose these duplicate connections until only one
Expand Down

0 comments on commit b321922

Please sign in to comment.