@@ -67,8 +67,8 @@ export function parseHumanFileSize(humanSize: string): number {
6767 throw new Error ( "Invalid file size format" ) ;
6868 }
6969
70- const size = parseFloat ( match [ 1 ] ) ; // Convert the number part to a float
71- const unit = match [ 3 ] . toUpperCase ( ) ; // Get the unit part and convert to uppercase for consistency
70+ const size = parseFloat ( match [ 1 ] || "" ) ; // Convert the number part to a float
71+ const unit = ( match [ 3 ] || "" ) . toUpperCase ( ) ; // Get the unit part and convert to uppercase for consistency
7272
7373 // Define units and their corresponding multiplier in bytes
7474 const units : { [ key : string ] : number } = {
@@ -214,7 +214,7 @@ export function parseFirstNameLastName(name: string) {
214214
215215 let nameArray = name . split ( " " ) ;
216216 if ( nameArray . length === 1 ) {
217- lastName = nameArray [ 0 ] ;
217+ lastName = nameArray [ 0 ] || "" ;
218218 } else if ( nameArray . length > 1 ) {
219219 lastName = nameArray . pop ( ) || "" ;
220220 firstName = nameArray . join ( " " ) ;
@@ -258,7 +258,7 @@ export function parseCertificationType(input: string): CertificationType {
258258 * @returns {string } - The highest certification name based on the defined weights.
259259 * @throws {Error } - If no valid certification type is found in the options.
260260 */
261- export function getHighestCertificationType ( options : CertificationComparison [ ] ) : CertificationType {
261+ export function getHighestCertificationType ( options : CertificationComparison [ ] ) : CertificationType | undefined {
262262 const parsed = options
263263 . map ( ( o ) => certificationTypeMap [ o . bcCertificate ! ] ) // map raw → enum
264264 . filter ( ( c ) : c is CertificationType => ! ! c ) ; // drop unrecognized
@@ -267,7 +267,7 @@ export function getHighestCertificationType(options: CertificationComparison[]):
267267 throw new Error ( "No valid certification found in options" ) ;
268268 }
269269
270- return parsed . reduce ( ( best , curr ) => ( certificationWeights [ curr ] > certificationWeights [ best ] ? curr : best ) , parsed [ 0 ] ) ;
270+ return parsed . reduce ( ( best , curr ) => ( certificationWeights [ curr ] > certificationWeights [ best ! ] ? curr : best ) , parsed [ 0 ] ) ;
271271}
272272
273273/**
0 commit comments