mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
clean up randomWords signature
This commit is contained in:
parent
1e807c741e
commit
67b4a05878
@ -315,6 +315,10 @@ type RandomWordsOptions = {
|
||||
join?: string;
|
||||
};
|
||||
|
||||
type RandomWordsResult<T extends RandomWordsOptions> = T extends { join: string }
|
||||
? string
|
||||
: string[];
|
||||
|
||||
/**
|
||||
* Generate one or more random words.
|
||||
*
|
||||
@ -325,11 +329,9 @@ type RandomWordsOptions = {
|
||||
*
|
||||
* @returns An array of words or a single string, depending on parameter choices.
|
||||
*/
|
||||
export function randomWords<T extends RandomWordsOptions>(
|
||||
opts: T
|
||||
): T extends { join: string } ? string : string[] {
|
||||
export function randomWords<T extends RandomWordsOptions>(opts: T) {
|
||||
// there is a type incompatibility here because `random-words` uses overloads rather than generics
|
||||
return rw(opts) as any;
|
||||
return rw(opts) as RandomWordsResult<T>;
|
||||
}
|
||||
|
||||
// Box-Muller transformation for a random sample from normal distribution with mean = 0, std = 1
|
||||
|
Loading…
Reference in New Issue
Block a user