mirror of
https://github.com/TheNetsky/Microsoft-Rewards-Script.git
synced 2026-01-18 14:03:58 +00:00
1.2.0
This commit is contained in:
@@ -7,17 +7,17 @@ export function log(title: string, message: string, type?: 'log' | 'warn' | 'err
|
||||
|
||||
switch (type) {
|
||||
case 'warn':
|
||||
str = `[${currentTime}] [WARN] [${title}] ${message}`
|
||||
str = `[${currentTime}] [PID: ${process.pid}] [WARN] [${title}] ${message}`
|
||||
console.warn(str)
|
||||
break
|
||||
|
||||
case 'error':
|
||||
str = `[${currentTime}] [ERROR] [${title}] ${message}`
|
||||
str = `[${currentTime}] [PID: ${process.pid}] [ERROR] [${title}] ${message}`
|
||||
console.error(str)
|
||||
break
|
||||
|
||||
default:
|
||||
str = `[${currentTime}] [LOG] [${title}] ${message}`
|
||||
str = `[${currentTime}] [PID: ${process.pid}] [LOG] [${title}] ${message}`
|
||||
console.log(str)
|
||||
break
|
||||
}
|
||||
|
||||
@@ -13,8 +13,7 @@ export function getFormattedDate(ms = Date.now()) {
|
||||
return `${month}/${day}/${year}`
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
export function shuffleArray(array: any[]): any[] {
|
||||
export function shuffleArray<T>(array: T[]): T[] {
|
||||
const shuffledArray = array.slice()
|
||||
|
||||
shuffledArray.sort(() => Math.random() - 0.5)
|
||||
@@ -24,4 +23,16 @@ export function shuffleArray(array: any[]): any[] {
|
||||
|
||||
export function randomNumber(min: number, max: number) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min
|
||||
}
|
||||
|
||||
export function chunkArray<T>(arr: T[], numChunks: number): T[][] {
|
||||
const chunkSize = Math.ceil(arr.length / numChunks)
|
||||
const chunks: T[][] = []
|
||||
|
||||
for (let i = 0; i < arr.length; i += chunkSize) {
|
||||
const chunk = arr.slice(i, i + chunkSize)
|
||||
chunks.push(chunk)
|
||||
}
|
||||
|
||||
return chunks
|
||||
}
|
||||
Reference in New Issue
Block a user