Skip to content

Commit

Permalink
refactor: revert breaking change, leave as comments for next major
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jan 24, 2024
1 parent 4dad8c7 commit 7cb8fe9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/config/configStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import { ConfigContents, ConfigEntry, ConfigValue, Key } from './configStackType
export interface ConfigStore<P extends ConfigContents = ConfigContents> {
// Map manipulation methods
entries(): ConfigEntry[];
get<K extends Key<P>>(key: K, decrypt: boolean): P[K] | undefined;
get<T extends ConfigValue>(key: string, decrypt: boolean): T | undefined;
// NEXT_RELEASE: update types to specify return can be P[K] | undefined
get<K extends Key<P>>(key: K, decrypt: boolean): P[K];
// NEXT_RELEASE: update types to specify return can be T | undefined
get<T extends ConfigValue>(key: string, decrypt: boolean): T;
getKeysByValue(value: ConfigValue): Array<Key<P>>;
has(key: string): boolean;
keys(): Array<Key<P>>;
Expand Down Expand Up @@ -88,9 +90,13 @@ export abstract class BaseConfigStore<
* @param decrypt If it is an encrypted key, decrypt the value.
* If the value is an object, a clone will be returned.
*/
public get<K extends Key<P>>(key: K, decrypt?: boolean): P[K] | undefined;
public get<V = ConfigValue>(key: string, decrypt?: boolean): V | undefined;
public get<K extends Key<P>>(key: K | string, decrypt = false): P[K] | ConfigValue | undefined {
// NEXT_RELEASE: update types to specify return can be | undefined
public get<K extends Key<P>>(key: K, decrypt?: boolean): P[K];
// NEXT_RELEASE: update types to specify return can be | undefined
// NEXT_RELEASE: consider getting rid of ConfigValue and letting it just use the Key<> approach
public get<V = ConfigValue>(key: string, decrypt?: boolean): V;
// NEXT_RELEASE: update types to specify return can be | undefined
public get<K extends Key<P>>(key: K | string, decrypt = false): P[K] | ConfigValue {
const rawValue = this.contents.get(key as K);

if (this.hasEncryption() && decrypt) {
Expand All @@ -100,6 +106,7 @@ export abstract class BaseConfigStore<
return this.decrypt(rawValue) as P[K] | ConfigValue;
}
}
// NEXT_RELEASE: update types to specify return can be | undefined
return rawValue as P[K] | ConfigValue;
}

Expand Down

2 comments on commit 7cb8fe9

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: 7cb8fe9 Previous: 4dad8c7 Ratio
Child logger creation 476616 ops/sec (±1.29%) 464655 ops/sec (±2.43%) 0.97
Logging a string on root logger 788221 ops/sec (±6.51%) 727812 ops/sec (±7.60%) 0.92
Logging an object on root logger 603584 ops/sec (±9.84%) 607337 ops/sec (±8.34%) 1.01
Logging an object with a message on root logger 8316 ops/sec (±207.01%) 8341 ops/sec (±204.87%) 1.00
Logging an object with a redacted prop on root logger 461785 ops/sec (±9.52%) 444544 ops/sec (±6.75%) 0.96
Logging a nested 3-level object on root logger 387465 ops/sec (±7.00%) 353721 ops/sec (±7.60%) 0.91

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: 7cb8fe9 Previous: 4dad8c7 Ratio
Child logger creation 316559 ops/sec (±0.92%) 338956 ops/sec (±0.43%) 1.07
Logging a string on root logger 734913 ops/sec (±6.00%) 820024 ops/sec (±10.06%) 1.12
Logging an object on root logger 566267 ops/sec (±4.03%) 592522 ops/sec (±8.99%) 1.05
Logging an object with a message on root logger 13216 ops/sec (±188.13%) 7361 ops/sec (±203.74%) 0.56
Logging an object with a redacted prop on root logger 469408 ops/sec (±6.72%) 466039 ops/sec (±6.85%) 0.99
Logging a nested 3-level object on root logger 321469 ops/sec (±5.82%) 315877 ops/sec (±10.77%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.