chore: apply Biome hints

Co-authored-by: Alexis Métaireau <alexis@notmyidea.org>
This commit is contained in:
Yohan Boniface 2024-10-24 12:35:17 +02:00
parent 45f1221d00
commit 200e12e0d9
6 changed files with 24 additions and 20 deletions

View file

@ -1,5 +1,5 @@
import { WithTemplate } from './utils.js'
import { translate } from './i18n.js'
import { WithTemplate } from './utils.js'
const TOOLBOX_TEMPLATE = `
<ul class="umap-slideshow-toolbox dark">

View file

@ -1,7 +1,7 @@
import * as Utils from '../utils.js'
import { HybridLogicalClock } from './hlc.js'
import { DataLayerUpdater, FeatureUpdater, MapUpdater } from './updaters.js'
import { WebSocketTransport } from './websocket.js'
import { HybridLogicalClock } from './hlc.js'
import * as Utils from '../utils.js'
/**
* The syncEngine exposes an API to sync messages between peers over the network.
@ -81,7 +81,7 @@ export class SyncEngine {
}
_send(inputMessage) {
let message = this._operations.addLocal(inputMessage)
const message = this._operations.addLocal(inputMessage)
if (this.offline) return
if (this.transport) {
@ -154,7 +154,7 @@ export class SyncEngine {
this.onListPeersResponse({ peers })
// Get one peer at random
let randomPeer = this._getRandomPeer()
const randomPeer = this._getRandomPeer()
if (randomPeer) {
// Retrieve the operations which happened before join.
@ -254,7 +254,7 @@ export class SyncEngine {
* @returns {string|bool} the selected peer uuid, or False if none was found.
*/
_getRandomPeer() {
let otherPeers = this.peers.filter((p) => p !== this.uuid)
const otherPeers = this.peers.filter((p) => p !== this.uuid)
if (otherPeers.length > 0) {
const random = Math.floor(Math.random() * otherPeers.length)
return otherPeers[random]
@ -308,7 +308,7 @@ export class Operations {
* @returns {*} clock-aware message
*/
addLocal(inputMessage) {
let message = { ...inputMessage, hlc: this._hlc.tick() }
const message = { ...inputMessage, hlc: this._hlc.tick() }
this._operations.push(message)
return message
}
@ -348,7 +348,7 @@ export class Operations {
*/
storeRemoteOperations(remoteOperations) {
// get the highest date from the passed operations
let greatestHLC = remoteOperations
const greatestHLC = remoteOperations
.map((op) => op.hlc)
.reduce((max, current) => (current > max ? current : max))

View file

@ -30,12 +30,12 @@ export class HybridLogicalClock {
* @returns object
*/
parse(raw) {
let tokens = raw.split(':')
const tokens = raw.split(':')
if (tokens.length !== 3) {
throw new SyntaxError(`Unable to parse ${raw}`)
}
let [walltime, rawNN, id] = tokens
const [walltime, rawNN, id] = tokens
let nn = Number.parseInt(rawNN)
if (Number.isNaN(nn)) {
@ -92,7 +92,7 @@ export class HybridLogicalClock {
if (now > local.walltime && now > remote.walltime) {
nextValue = { ...local, walltime: now }
} else if (local.walltime == remote.walltime) {
let nn = Math.max(local.nn, remote.nn) + 1
const nn = Math.max(local.nn, remote.nn) + 1
nextValue = { ...local, nn: nn }
} else if (remote.walltime > local.walltime) {
nextValue = { ...remote, id: local.id, nn: remote.nn + 1 }

View file

@ -44,7 +44,7 @@ class BaseUpdater {
export class MapUpdater extends BaseUpdater {
update({ key, value }) {
if (fieldInSchema(key)){
if (fieldInSchema(key)) {
this.updateObjectValue(this.map, key, value)
}
@ -64,7 +64,10 @@ export class DataLayerUpdater extends BaseUpdater {
if (fieldInSchema(key)) {
this.updateObjectValue(datalayer, key, value)
} else {
console.debug('Not applying update for datalayer because key is not in the schema', key)
console.debug(
'Not applying update for datalayer because key is not in the schema',
key
)
}
datalayer.render([key])
}

View file

@ -35,7 +35,7 @@ export function checkId(string) {
* @returns Array[string]
*/
export function getImpactsFromSchema(fields, schema) {
schema = schema || U.SCHEMA
const current_schema = schema || U.SCHEMA
const impacted = fields
.map((field) => {
// remove the option prefix for fields
@ -46,8 +46,10 @@ export function getImpactsFromSchema(fields, schema) {
.reduce((acc, field) => {
// retrieve the "impacts" field from the schema
// and merge them together using sets
const impacts = schema[field]?.impacts || []
impacts.forEach((impact) => acc.add(impact))
const impacts = current_schema[field]?.impacts || []
for (const impact of impacts) {
acc.add(impact)
}
return acc
}, new Set())
@ -62,10 +64,10 @@ export function getImpactsFromSchema(fields, schema) {
* @returns {boolean}
*/
export function fieldInSchema(field, schema) {
const current_schema = schema || U.SCHEMA
if (typeof field !== 'string') return false
field = field.replace('options.', '').split('.')[0]
schema = schema || U.SCHEMA
return schema[field] !== undefined
const field_name = field.replace('options.', '').split('.')[0]
return current_schema[field_name] !== undefined
}
/**

View file

@ -224,7 +224,6 @@ U.Map = L.Map.extend({
},
render: function (fields) {
if (fields.includes('numberOfConnectedPeers')) {
this.renderEditToolbar()
this.propagate()