mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
re-organize attachment functions and updated comments doc
This commit is contained in:
committed by
Junyoung Choi
parent
8355e1e006
commit
0b84a372f6
@@ -136,9 +136,24 @@ export function isMarkdownTitleURL (str) {
|
||||
return /(^#{1,6}\s)(?:\w+:|^)\/\/(?:[^\s\.]+\.\S{2}|localhost[\:?\d]*)/.test(str)
|
||||
}
|
||||
|
||||
export function humanFileSize (bytes) {
|
||||
const threshold = 1000
|
||||
if (Math.abs(bytes) < threshold) {
|
||||
return bytes + ' B'
|
||||
}
|
||||
var units = ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
|
||||
var u = -1
|
||||
do {
|
||||
bytes /= threshold
|
||||
++u
|
||||
} while (Math.abs(bytes) >= threshold && u < units.length - 1)
|
||||
return bytes.toFixed(1) + ' ' + units[u]
|
||||
}
|
||||
|
||||
export default {
|
||||
lastFindInArray,
|
||||
escapeHtmlCharacters,
|
||||
isObjectEqual,
|
||||
isMarkdownTitleURL
|
||||
isMarkdownTitleURL,
|
||||
humanFileSize
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user