MCPcopy Index your code
hub / github.com/SoftwareBrothers/adminjs / selectParams

Function selectParams

src/utils/flat/select-params.ts:12–35  ·  view source on GitHub ↗
(
  params: FlattenParams,
  properties: string | Array<string>,
  options?: GetOptions,
)

Source from the content-addressed store, hash-verified

10 * @returns {FlattenParams}
11 */
12const selectParams = (
13 params: FlattenParams,
14 properties: string | Array<string>,
15 options?: GetOptions,
16): FlattenParams => {
17 const propertyArray = Array.isArray(properties) ? properties : [properties]
18 const selected = propertyArray
19 .filter((propertyPath) => !!propertyPath)
20 .reduce((globalMemo, propertyPath) => {
21 const regex = propertyKeyRegex(propertyPath, options)
22 const filtered = Object.keys(params)
23 // filter all keys which starts with property path
24 .filter((key) => key.match(regex))
25 .reduce((memo, key) => {
26 memo[key] = (params[key] as string)
27 return memo
28 }, {} as FlattenParams)
29 return {
30 ...globalMemo,
31 ...filtered,
32 }
33 }, {} as FlattenParams)
34 return selected
35}
36
37export { selectParams }

Callers 2

getFunction · 0.85

Calls 3

propertyKeyRegexFunction · 0.85
reduceMethod · 0.80
isArrayMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…