|
|
@ -108,18 +108,14 @@ const getAvailableRollupForUiType = (type: string) => { |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getFileName = ({ |
|
|
|
const getFileName = ({ name, count, ext }) => |
|
|
|
name, |
|
|
|
`${name}${count ? `(${count})` : ''}${ext ? `${ext}` : ''}`; |
|
|
|
count, |
|
|
|
|
|
|
|
ext |
|
|
|
|
|
|
|
}) => `${name}${count ? `(${count})` : ''}${ext? `${ext}` : ''}` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// add count before extension if duplicate name found
|
|
|
|
// add count before extension if duplicate name found
|
|
|
|
function populateUniqueFileName( |
|
|
|
function populateUniqueFileName(fileName: string, attachments: string[]) { |
|
|
|
fileName: string, |
|
|
|
return fileName.replace( |
|
|
|
attachments: string[] |
|
|
|
/^(.+?)(?:\((\d+)\))?(\.(?:tar|min)\.(?:\w{2,4})|\.\w+)$/, |
|
|
|
) { |
|
|
|
(fileName, name, count, ext) => { |
|
|
|
return fileName.replace(/^(.+?)(?:\((\d+)\))?(\.(?:tar|min)\.(?:\w{2,4})|\.\w+)$/, (fileName,name, count, ext) =>{ |
|
|
|
|
|
|
|
let genFileName = fileName; |
|
|
|
let genFileName = fileName; |
|
|
|
let c = count || 1; |
|
|
|
let c = count || 1; |
|
|
|
|
|
|
|
|
|
|
@ -128,11 +124,30 @@ function populateUniqueFileName( |
|
|
|
genFileName = getFileName({ |
|
|
|
genFileName = getFileName({ |
|
|
|
name, |
|
|
|
name, |
|
|
|
ext, |
|
|
|
ext, |
|
|
|
count: c++ |
|
|
|
count: c++, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return genFileName; |
|
|
|
return genFileName; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function roundUpToPrecision(number: number, precision: number = 0) { |
|
|
|
|
|
|
|
precision = |
|
|
|
|
|
|
|
precision == null |
|
|
|
|
|
|
|
? 0 |
|
|
|
|
|
|
|
: precision >= 0 |
|
|
|
|
|
|
|
? Math.min(precision, 292) |
|
|
|
|
|
|
|
: Math.max(precision, -292); |
|
|
|
|
|
|
|
if (precision) { |
|
|
|
|
|
|
|
// Shift with exponential notation to avoid floating-point issues.
|
|
|
|
|
|
|
|
// See [MDN](https://mdn.io/round#Examples) for more details.
|
|
|
|
|
|
|
|
let pair = `${number}e`.split('e'); |
|
|
|
|
|
|
|
const value = Math.round(Number(`${pair[0]}e${+pair[1] + precision}`)); |
|
|
|
|
|
|
|
pair = `${value}e`.split('e'); |
|
|
|
|
|
|
|
return +`${pair[0]}e${+pair[1] - precision}`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return Math.round(number); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export { |
|
|
|
export { |
|
|
@ -145,4 +160,5 @@ export { |
|
|
|
stringifyRolesObj, |
|
|
|
stringifyRolesObj, |
|
|
|
getAvailableRollupForUiType, |
|
|
|
getAvailableRollupForUiType, |
|
|
|
populateUniqueFileName, |
|
|
|
populateUniqueFileName, |
|
|
|
|
|
|
|
roundUpToPrecision, |
|
|
|
}; |
|
|
|
}; |
|
|
|