diff --git a/MIGRATING_V5-V6.md b/MIGRATING_V5-V6.md index 1d24cc8650..21a8bdac38 100644 --- a/MIGRATING_V5-V6.md +++ b/MIGRATING_V5-V6.md @@ -13,8 +13,9 @@ But that comes with breaking changes to to reduce the risk of "getting around" t - AuthInfo.getFields now returns a read-only object. Use AuthInfo.update to change values in the fields. - `setContents` method is no longer available in the ConfigFile stack. Use `update` to merge in multiple props, or `set/unset` on a single prop. - `write` and `writeSync` method no longer accepts a param. Use other methods (`set`, `unset`, `update) to make modifications, then call write()/writeSync() to do the write. -- the use of lodash-style `get`/`set` (ex: `set('foo.bar.baz[0]', 3)`) no longer works. -- You can no longer override the `setMethod` and `getMethod`` when extending classes built on ConfigFile. Technically you could override get/set, but DON'T! +- the use of lodash-style `get`/`set`/`unset`/`unsetAll` (ex: `set('foo.bar.baz[0]', 3)`) no longer works. +- `awaitEach` is removed +- You can no longer override the `setMethod` and `getMethod` when extending classes built on ConfigFile. Technically you could override get/set, but DON'T! - Everything related to tokens/tokenConfig is gone ## Unrelated changes that we did because it's a major version diff --git a/src/config/configStore.ts b/src/config/configStore.ts index 389b846e37..99f4a42460 100644 --- a/src/config/configStore.ts +++ b/src/config/configStore.ts @@ -35,7 +35,6 @@ export interface ConfigStore

{ values(): ConfigValue[]; forEach(actionFn: (key: string, value: ConfigValue) => void): void; - awaitEach(actionFn: (key: string, value: ConfigValue) => Promise): Promise; // Content methods getContents(): P; @@ -188,7 +187,7 @@ export abstract class BaseConfigStore< * Returns `true` if all elements in the config object existed and have been removed, or `false` if all the elements * do not exist (some may have been removed). {@link BaseConfigStore.has(key)} will return false afterwards. * - * @param keys The keys. Supports query keys like `a.b[0]`. + * @param keys The keys */ public unsetAll(keys: Array>): boolean { return keys.map((key) => this.unset(key)).every(Boolean); @@ -234,18 +233,6 @@ export abstract class BaseConfigStore< this.entries().map((entry) => actionFn(entry[0], entry[1])); } - /** - * Asynchronously invokes `actionFn` once for each key-value pair present in the config object. - * - * @param {function} actionFn The function `(key: string, value: ConfigValue) => Promise` to be called for - * each element. - * @returns {Promise} - */ - public async awaitEach(actionFn: (key: string, value: ConfigValue) => Promise): Promise { - const entries = this.entries(); - await Promise.all(entries.map((entry) => actionFn(entry[0], entry[1]))); - } - /** * Convert the config object to a JSON object. Returns the config contents. * Same as calling {@link ConfigStore.getContents} @@ -266,7 +253,8 @@ export abstract class BaseConfigStore< }); } - /** Keep ConfigFile concurrency-friendly. + /** + * Keep ConfigFile concurrency-friendly. * Avoid using this unless you're reading the file for the first time * and guaranteed to no be cross-saving existing contents * */ diff --git a/src/config/lwwMap.ts b/src/config/lwwMap.ts index 0cd5b4d258..0a298a7bfa 100644 --- a/src/config/lwwMap.ts +++ b/src/config/lwwMap.ts @@ -54,9 +54,7 @@ export class LWWMap

{ public get state(): LWWState

{ return Object.fromEntries( - Array.from(this.#data.entries()) - // .filter(([, register]) => Boolean(register)) - .map(([key, register]) => [key, register.state]) + Array.from(this.#data.entries()).map(([key, register]) => [key, register.state]) ) as LWWState

; } diff --git a/test/unit/config/configStoreTest.ts b/test/unit/config/configStoreTest.ts index 7dd2805d98..577cff023e 100644 --- a/test/unit/config/configStoreTest.ts +++ b/test/unit/config/configStoreTest.ts @@ -48,17 +48,6 @@ describe('ConfigStore', () => { }); expect(st).to.equal('1a2b'); }); - it('await each value', async () => { - const config = await TestConfig.create(); - config.set('1', 'a'); - config.set('2', 'b'); - - let st = ''; - await config.awaitEach(async (key, val) => { - st += `${key}${val}`; - }); - expect(st).to.equal('1a2b'); - }); it('returns the object reference', async () => { const config = new TestConfig<{ '1': { a: string } }>();