From b3219223c24facce05b25b725bd9076742d2368e Mon Sep 17 00:00:00 2001 From: Evan Hahn Date: Mon, 25 Mar 2024 12:52:18 -0500 Subject: [PATCH] chore: use the same `noop` everywhere (#511) This minor cleanup uses the same `noop` utility function across the codebase, rather than defining them as one-offs. Co-authored-by: Gregor MacLennan --- src/datatype/index.js | 4 +--- src/discovery/local-discovery.js | 3 +-- src/local-peers.js | 4 +--- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/datatype/index.js b/src/datatype/index.js index 6f386c9b4..7870d296c 100644 --- a/src/datatype/index.js +++ b/src/datatype/index.js @@ -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' @@ -291,5 +291,3 @@ export class DataType extends TypedEmitter { this.emit('updated-docs', updatedDocs) } } - -function noop() {} diff --git a/src/discovery/local-discovery.js b/src/discovery/local-discovery.js index 6d3d59eed..33ea5203b 100644 --- a/src/discovery/local-discovery.js +++ b/src/discovery/local-discovery.js @@ -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' @@ -299,5 +300,3 @@ function getAddress(server) { } return addr } - -function noop() {} diff --git a/src/local-peers.js b/src/local-peers.js index 5e8136a9b..718aaa150 100644 --- a/src/local-peers.js +++ b/src/local-peers.js @@ -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 { @@ -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