cognitive-complexity-ts
Version:
This program analyses TypeScript and JavaScript code according to the [Cognitive Complexity metric](https://www.sonarsource.com/docs/CognitiveComplexity.pdf). It produces a JSON summary and a GUI for exploring the complexity of your codebase.
22 lines (21 loc) • 1.15 kB
TypeScript
export declare function doesNotThrow<T>(promise: Promise<T>): Promise<boolean>;
/**
* Builds an object from a list of keys whose values are based on the key itself,
* but where that value is produced asynchronously.
*
* This function starts by spawning a promise to generate the value for each key,
* and ends when all values have been produced.
* This is faster than spawning promises in sequence.
*/
export declare function keysToAsyncValues<K extends keyof any, V>(keys: K[], toValue: (elem: K) => Promise<V>): Promise<Record<K, V>>;
/**
* Builds an object from a list of input items.
* The keys and values are derived from the input item,
* but the values either need to be generated asynchronously or not at all.
*/
export declare function createObjectOfPromisedValues<I, K extends keyof any, V>(inputs: I[], toKey: (input: I) => K, toMaybePromise: (input: I) => Promise<V> | undefined): Promise<Record<K, V>>;
export declare function nonNaN(num: number, fallback: number): number;
export declare function repeat(str: string, times: number): string;
export declare class Unreachable extends Error {
constructor(reason: string);
}