-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: more elegant
process.env
handling
- Loading branch information
1 parent
5e39d17
commit ac14883
Showing
13 changed files
with
101 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'dotenv/config' | ||
import type { LitterboxExpiration } from './types/data.js' | ||
|
||
export const DEFAULT_LANG = process.env.DEFAULT_LANG | ||
export const DEFAULT_SERVICE = process.env.DEFAULT_SERVICE | ||
export const DEFAULT_EXPR = parseInt(process.env.DEFAULT_EXPR) as LitterboxExpiration | ||
export const ADMIN_ID = parseInt(process.env.ADMIN_ID) | ||
export const MAX_DOWNLOADING = parseInt(process.env.MAX_DOWNLOADING) | ||
export const BOT_TOKEN = process.env.BOT_TOKEN | ||
export const API_ID = parseInt(process.env.API_ID) | ||
export const API_HASH = process.env.API_HASH | ||
export const LOG_CHANNEL_ID = parseInt(process.env.LOG_CHANNEL_ID) | ||
export const CATBOX_TOKEN = process.env.CATBOX_TOKEN | ||
export const DOWNLOAD_DC_ID = parseInt(process.env.DOWNLOAD_DC_ID) || 5 | ||
export const DOWNLOAD_WORKERS = parseInt(process.env.DOWNLOAD_WORKERS) || 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
async function fetchData(page: number) { | ||
return new Promise(resolve => { | ||
setTimeout(() => { | ||
resolve(`Page: ${page}`) | ||
}, 1000) | ||
}) | ||
} | ||
|
||
async function* asyncDataGenerator(pages: number) { | ||
for (let i = 1; i <= pages; i++) { | ||
yield await fetchData(i) | ||
} | ||
} | ||
|
||
;(async () => { | ||
const generator = asyncDataGenerator(4) | ||
await new Promise(resolve => setTimeout(resolve, 2000)) | ||
console.log(await generator.next()) | ||
console.log(await generator.next()) | ||
console.log(await generator.next()) | ||
await generator.return() | ||
console.log(await generator.next()) | ||
console.log(await generator.next()) | ||
// for await (const data of generator) { | ||
// console.log(data) | ||
// } | ||
})() |