2022-04-22 13:05:56 +10:00
|
|
|
import FileSaver from 'file-saver'
|
|
|
|
|
|
|
|
export * from './crypto'
|
|
|
|
export * from './debounce'
|
|
|
|
export * from './adapters'
|
|
|
|
export * from './storeUtils'
|
|
|
|
export * from './stringUtils'
|
|
|
|
export * from './numberUtils'
|
|
|
|
export * from './instanceUtils'
|
|
|
|
|
2022-11-11 02:01:46 +00:00
|
|
|
export function flattenNArray(arr) {
|
|
|
|
return arr.reduce((flat, toFlatten) => {
|
|
|
|
return flat.concat(Array.isArray(toFlatten) ? flattenNArray(toFlatten) : toFlatten)
|
|
|
|
}, [])
|
|
|
|
}
|
|
|
|
|
2022-04-22 13:05:56 +10:00
|
|
|
export function sleep(ms) {
|
|
|
|
return new Promise((resolve) => setTimeout(resolve, ms))
|
|
|
|
}
|
|
|
|
|
|
|
|
export function detectMob() {
|
|
|
|
if (
|
|
|
|
navigator.userAgent.match(/Android/i) ||
|
|
|
|
navigator.userAgent.match(/webOS/i) ||
|
|
|
|
navigator.userAgent.match(/iPhone/i) ||
|
|
|
|
navigator.userAgent.match(/iPad/i) ||
|
|
|
|
navigator.userAgent.match(/iPod/i) ||
|
|
|
|
navigator.userAgent.match(/BlackBerry/i) ||
|
|
|
|
navigator.userAgent.match(/Windows Phone/i)
|
|
|
|
) {
|
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function saveAsFile(data, name) {
|
|
|
|
if (detectMob()) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
FileSaver.saveAs(data, name)
|
|
|
|
}
|