Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | 4x 15x 15x 15x 4x 13x 13x 4x 9x 4x 4x 2x 2x | import type { IChromeConfig } from './interfaces/interfaces'
import type { OSSetting, OS, ExtendedOS } from './interfaces/os.interfaces'
import type { IListStore, ISetStore } from './interfaces/store.interfaces'
export function detectOperatingSystem(config: IChromeConfig): OSSetting {
const is64Bit = config.arch === 'x64'
switch (config.os) {
case 'linux':
return is64Bit
? {
url: 'Linux_x64',
filename: 'linux'
}
: {
url: 'Linux',
filename: 'linux'
}
case 'win':
return is64Bit
? {
url: 'Win_x64',
filename: 'win'
}
: {
url: 'Win',
filename: 'win'
}
case 'mac':
return config.arch === 'arm'
? {
url: 'Mac_Arm',
filename: 'mac'
}
: {
url: 'Mac',
filename: 'mac'
}
default:
throw new Error(`Unsupported operation system: ${config.os}`)
}
}
export function mapOS(extendedOS: string): OS {
switch (extendedOS as ExtendedOS) {
case 'linux':
return 'linux'
case 'win32':
case 'win':
return 'win'
case 'darwin':
case 'mac':
return 'mac'
}
throw new Error(`unknown OS: ${extendedOS}`)
}
export function setStoreToListStore(setStore: ISetStore): IListStore {
return {
linux: {
x64: [...setStore.linux.x64],
x86: [...setStore.linux.x86],
},
win: {
x64: [...setStore.win.x64],
x86: [...setStore.win.x86],
},
mac: {
x64: [...setStore.mac.x64],
arm: [...setStore.mac.arm],
},
}
}
export async function waitFor(milliseconds: number): Promise<void> {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, milliseconds)
})
}
export function* popArray<T>(array: T[]): Generator<T, void, void> {
for(const element of array) {
yield element
}
}
|