(code: number, type: keyof DefaultOptions, opts?: PickByHashCodeOpts)
| 114 | usually?: string[] |
| 115 | } |
| 116 | const pickByHashCode = (code: number, type: keyof DefaultOptions, opts?: PickByHashCodeOpts): string => { |
| 117 | const avoidList = opts && opts.avoidList || [] |
| 118 | const usually = opts && opts.usually || [] |
| 119 | |
| 120 | // Filter out avoid options |
| 121 | const avoidSet = new Set<string>(avoidList) |
| 122 | let myDefaultOptions = defaultOptions[type].filter(item => !avoidSet.has(item)) |
| 123 | |
| 124 | // Increase selecting possibility of usually options |
| 125 | myDefaultOptions = usually |
| 126 | .filter(Boolean) |
| 127 | .reduce( |
| 128 | (acc, cur) => acc.concat(new Array(15).fill(cur)), |
| 129 | [] as string[] |
| 130 | ) |
| 131 | .concat(myDefaultOptions) |
| 132 | |
| 133 | const index = code % myDefaultOptions.length |
| 134 | return myDefaultOptions[index] |
| 135 | } |
| 136 | |
| 137 | export const genConfig: GenConfigFunc = (userConfig = {}) => { |
| 138 | const isSeedConfig = typeof userConfig === 'string'; |
no outgoing calls
no test coverage detected
searching dependent graphs…