From 081cc05fa65868ddeb5601ae33b64321db078ad5 Mon Sep 17 00:00:00 2001 From: Isaiah Becker-Mayer Date: Sat, 9 Jul 2022 11:53:09 -0400 Subject: [PATCH] Updates comparator --- src/observable/list/BaseObservableList.ts | 2 +- src/observable/list/SortedArray.ts | 6 +++--- src/observable/list/SortedMapList.js | 4 ++-- src/observable/map/ApplyMap.ts | 2 +- src/observable/map/BaseObservableMap.ts | 4 ++-- src/observable/map/FilteredMap.ts | 2 +- src/observable/map/JoinedMap.ts | 2 +- src/observable/map/LogMap.ts | 4 ++-- src/observable/map/MappedMap.ts | 2 +- src/observable/map/ObservableMap.ts | 4 ++-- src/observable/map/config.ts | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/observable/list/BaseObservableList.ts b/src/observable/list/BaseObservableList.ts index d103eb64..e2806c72 100644 --- a/src/observable/list/BaseObservableList.ts +++ b/src/observable/list/BaseObservableList.ts @@ -31,7 +31,7 @@ export function defaultObserverWith(overrides: { [key in keyof IListObserver< onUpdate(){}, onRemove(){}, onMove(){}, - } + }; return Object.assign(defaults, overrides); } diff --git a/src/observable/list/SortedArray.ts b/src/observable/list/SortedArray.ts index c85cca27..7df285a5 100644 --- a/src/observable/list/SortedArray.ts +++ b/src/observable/list/SortedArray.ts @@ -87,7 +87,7 @@ export class SortedArray extends BaseObservableList { const idx = sortedIndex(this._items, item, this._comparator); if (idx >= this._items.length || this._comparator(this._items[idx], item) !== 0) { this._items.splice(idx, 0, item); - this.emitAdd(idx, item) + this.emitAdd(idx, item); } else { this._items[idx] = item; this.emitUpdate(idx, item, updateParams); @@ -156,7 +156,7 @@ export function tests() { assert.equal(sa.get(0), "a"); assert.equal(sa.get(1), "b"); assert.equal(sa.get(2), "c"); - }, + }, "_getNext": assert => { const sa = new SortedArray((a, b) => a.localeCompare(b)); sa.setManyUnsorted(["b", "a", "f"]); @@ -183,5 +183,5 @@ export function tests() { // check done persists assert.equal(it.next().done, true); } - } + }; } diff --git a/src/observable/list/SortedMapList.js b/src/observable/list/SortedMapList.js index 21a3aa55..6f4be123 100644 --- a/src/observable/list/SortedMapList.js +++ b/src/observable/list/SortedMapList.js @@ -129,7 +129,7 @@ export class SortedMapList extends BaseObservableList { } return v; } - } + }; } } @@ -267,5 +267,5 @@ export function tests() { assert.equal(updateFired, 1); assert.deepEqual(Array.from(list).map(v => v.number), [1, 3, 11]); }, - } + }; } diff --git a/src/observable/map/ApplyMap.ts b/src/observable/map/ApplyMap.ts index da485af9..23b6f6ea 100644 --- a/src/observable/map/ApplyMap.ts +++ b/src/observable/map/ApplyMap.ts @@ -44,7 +44,7 @@ export class ApplyMap extends BaseObservableMap { return this._config.mapValues(this, mapper, updater); } - sortValues(comparator?: (a: any, b: any) => number): SortedMapList { + sortValues(comparator: (a: V, b: V) => number): SortedMapList { return this._config.sortValues(this, comparator); } diff --git a/src/observable/map/BaseObservableMap.ts b/src/observable/map/BaseObservableMap.ts index b2f63c03..37597932 100644 --- a/src/observable/map/BaseObservableMap.ts +++ b/src/observable/map/BaseObservableMap.ts @@ -30,7 +30,7 @@ export interface IMapObserver { export type BaseObservableMapConfig = { join(_this: BaseObservableMap, ...otherMaps: Array>): JoinedMap; mapValues(_this: BaseObservableMap, mapper: any, updater?: (params: any) => void): MappedMap; - sortValues(_this: BaseObservableMap, comparator?: (a: any, b: any) => number): SortedMapList; + sortValues(_this: BaseObservableMap, comparator: (a: V, b: V) => number): SortedMapList; filterValues(_this: BaseObservableMap, filter: (v: V, k: K) => boolean): FilteredMap; } @@ -68,7 +68,7 @@ export abstract class BaseObservableMap extends BaseObservable): JoinedMap; abstract mapValues(mapper: any, updater?: (params: any) => void): MappedMap; - abstract sortValues(comparator?: (a: any, b: any) => number): SortedMapList; + abstract sortValues(comparator: (a: V, b: V) => number): SortedMapList; abstract filterValues(filter: (v: V, k: K) => boolean): FilteredMap; abstract [Symbol.iterator](): Iterator<[K, V]>; diff --git a/src/observable/map/FilteredMap.ts b/src/observable/map/FilteredMap.ts index 8b544072..41017bfd 100644 --- a/src/observable/map/FilteredMap.ts +++ b/src/observable/map/FilteredMap.ts @@ -43,7 +43,7 @@ export class FilteredMap extends BaseObservableMap { return this._config.mapValues(this, mapper, updater); } - sortValues(comparator?: (a: any, b: any) => number): SortedMapList { + sortValues(comparator: (a: V, b: V) => number): SortedMapList { return this._config.sortValues(this, comparator); } diff --git a/src/observable/map/JoinedMap.ts b/src/observable/map/JoinedMap.ts index fbf2f39d..8973f1bf 100644 --- a/src/observable/map/JoinedMap.ts +++ b/src/observable/map/JoinedMap.ts @@ -41,7 +41,7 @@ export class JoinedMap extends BaseObservableMap { return this._config.mapValues(this, mapper, updater); } - sortValues(comparator?: (a: any, b: any) => number): SortedMapList { + sortValues(comparator: (a: V, b: V) => number): SortedMapList { return this._config.sortValues(this, comparator); } diff --git a/src/observable/map/LogMap.ts b/src/observable/map/LogMap.ts index a287014a..1417b14c 100644 --- a/src/observable/map/LogMap.ts +++ b/src/observable/map/LogMap.ts @@ -20,7 +20,7 @@ import {FilteredMap} from "./FilteredMap.js"; import {MappedMap} from "./MappedMap.js"; import {JoinedMap} from "./JoinedMap.js"; import {SortedMapList} from "../list/SortedMapList.js"; -import {SubscriptionHandle} from "../BaseObservable" +import {SubscriptionHandle} from "../BaseObservable"; import {ILogItem, LabelOrValues} from "../../logging/types"; import {LogLevel} from "../../logging/LogFilter"; @@ -46,7 +46,7 @@ export class LogMap extends BaseObservableMap { return this._config.mapValues(this, mapper, updater); } - sortValues(comparator?: (a: any, b: any) => number): SortedMapList { + sortValues(comparator: (a: V, b: V) => number): SortedMapList { return this._config.sortValues(this, comparator); } diff --git a/src/observable/map/MappedMap.ts b/src/observable/map/MappedMap.ts index ff522621..a3dbb000 100644 --- a/src/observable/map/MappedMap.ts +++ b/src/observable/map/MappedMap.ts @@ -54,7 +54,7 @@ export class MappedMap extends BaseObservableMap { return this._config.mapValues(this, mapper, updater); } - sortValues(comparator?: (a: any, b: any) => number): SortedMapList { + sortValues(comparator: (a: V, b: V) => number): SortedMapList { return this._config.sortValues(this, comparator); } diff --git a/src/observable/map/ObservableMap.ts b/src/observable/map/ObservableMap.ts index 06776927..169d2b58 100644 --- a/src/observable/map/ObservableMap.ts +++ b/src/observable/map/ObservableMap.ts @@ -40,7 +40,7 @@ export class ObservableMap extends BaseObservableMap { return this._config.mapValues(this, mapper, updater); } - sortValues(comparator?: (a: any, b: any) => number): SortedMapList { + sortValues(comparator: (a: V, b: V) => number): SortedMapList { return this._config.sortValues(this, comparator); } @@ -249,5 +249,5 @@ export function tests() { map.add(2, {number: 6}); assert.equal(map.size, 2); }, - } + }; } diff --git a/src/observable/map/config.ts b/src/observable/map/config.ts index c91cfe1a..8557031d 100644 --- a/src/observable/map/config.ts +++ b/src/observable/map/config.ts @@ -33,7 +33,7 @@ export function config(): BaseObservableMapConfig { mapValues: (_this: BaseObservableMap, mapper: any, updater: (params: any) => void): MappedMap => { return new MappedMap(_this, mapper, updater); }, - sortValues: (_this: BaseObservableMap, comparator?: (a: any, b: any) => number): SortedMapList => { + sortValues: (_this: BaseObservableMap, comparator: (a: V, b: V) => number): SortedMapList => { return new SortedMapList(_this, comparator); }, filterValues: (_this: BaseObservableMap, filter: (v: V, k: K) => boolean): FilteredMap => {