1
1
import parseAuthor from 'parse-author' ;
2
- import _ from 'lodash' ;
3
2
import { fromPromise } from 'universalify' ;
4
3
5
4
import * as getComponentFallback from './helpers/get-component-fallback' ;
@@ -11,19 +10,14 @@ import { Component, Config } from '../../types';
11
10
import { Request , Response } from 'express' ;
12
11
13
12
function getParams ( component : Component ) {
14
- let params = { } ;
13
+ let params : Record < string , string > = { } ;
15
14
if ( component . oc . parameters ) {
16
- const mandatoryParams = _ . filter (
17
- Object . keys ( component . oc . parameters || { } ) ,
18
- paramName => {
19
- const param = component . oc . parameters [ paramName ] ;
20
- return ! ! param . mandatory && ! ! param . example ;
21
- }
22
- ) ;
23
-
24
- params = _ . mapValues (
25
- _ . pick ( component . oc . parameters , mandatoryParams ) ,
26
- x => x . example
15
+ params = Object . fromEntries (
16
+ Object . entries ( component . oc . parameters || { } )
17
+ . filter ( ( [ , param ] ) => {
18
+ return ! ! param . mandatory && 'example' in param ;
19
+ } )
20
+ . map ( ( [ paramName , param ] ) => [ paramName , param . example ! ] )
27
21
) ;
28
22
}
29
23
@@ -60,11 +54,10 @@ function componentInfo(
60
54
const parsedAuthor = getParsedAuthor ( component ) ;
61
55
let href = res . conf . baseUrl ;
62
56
63
- const repositoryUrl = _ . get (
64
- component ,
65
- 'repository.url' ,
66
- typeof component . repository === 'string' ? component . repository : null
67
- ) ;
57
+ const repositoryUrl =
58
+ typeof component . repository === 'string'
59
+ ? component . repository
60
+ : component . repository ?. url ?? null ;
68
61
69
62
fromPromise ( isUrlDiscoverable ) ( href , ( _err , result ) => {
70
63
if ( ! result . isDiscoverable ) {
0 commit comments