File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,8 +41,9 @@ export function processDirectMethod(
4141 methodName . substring ( 0 , 1 ) . toUpperCase ( ) + methodName . substring ( 1 ) ;
4242 console . log ( `Processing Direct: ${ upperMethodName } ` ) ;
4343
44- const signature = ( direct . type as TypeDoc . ReflectionType ) . declaration
45- . signatures [ 0 ] ;
44+ const signatures = ( direct . type as TypeDoc . ReflectionType ) . declaration
45+ . signatures ;
46+ const signature = signatures [ signatures . length - 1 ] ;
4647
4748 writeApiDocsDirectPage ( methodName ) ;
4849 writeApiDocsData ( methodName , [
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ function processModuleMethod(module: TypeDoc.DeclarationReflection): PageIndex {
5050 ) ) {
5151 const methodName = method . name ;
5252 console . debug ( `- ${ methodName } ` ) ;
53- const signature = method . signatures [ 0 ] ;
53+ const signatures = method . signatures ;
54+ const signature = signatures [ signatures . length - 1 ] ;
5455
5556 methods . push ( analyzeSignature ( signature , lowerModuleName , methodName ) ) ;
5657 }
Original file line number Diff line number Diff line change @@ -179,6 +179,26 @@ export class Random {
179179 object : T ,
180180 field ?: unknown
181181 ) : T [ K ] ;
182+ /**
183+ * Returns a random key or value from given object.
184+ *
185+ * @template T The type of `Record` to pick from.
186+ * @template K The keys of `T`.
187+ * @param object The object to get the keys or values from.
188+ * @param field If this is set to `'key'`, this method will a return a random key of the given instance.
189+ * If this is set to `'value'`, this method will a return a random value of the given instance.
190+ * Defaults to `'value'`.
191+ *
192+ * @example
193+ * const object = { keyA: 'valueA', keyB: 42 };
194+ * faker.random.objectElement(object) // 42
195+ * faker.random.objectElement(object, 'key') // 'keyB'
196+ * faker.random.objectElement(object, 'value') // 'valueA'
197+ */
198+ objectElement < T extends Record < string , unknown > , K extends keyof T > (
199+ object : T ,
200+ field ?: 'key' | 'value'
201+ ) : K | T [ K ] ;
182202 objectElement < T extends Record < string , unknown > , K extends keyof T > (
183203 object = { foo : 'bar' , too : 'car' } as unknown as T ,
184204 field = 'value'
You can’t perform that action at this time.
0 commit comments