diff --git a/.swm/rate-limit-queue-overview.3c009.sw.md b/.swm/rate-limit-queue-overview.3c009.sw.md new file mode 100644 index 0000000..ca86ee7 --- /dev/null +++ b/.swm/rate-limit-queue-overview.3c009.sw.md @@ -0,0 +1,80 @@ +--- +id: 3c009 +name: Rate Limit Queue Overview +file_version: 1.0.2 +app_version: 0.8.9-2 +file_blobs: + src/queue.ts: e2a367fa5404b54e6bca8160935165f1f6d3ba5c + package.json: 4790390936c7adcc4a21829b599e08a46798e597 + tsconfig.json: ced946be08b6157720abbd71e4da1a716bf00c1f +--- + +The rate limit queue can be used to queue & distribute API calls evenly over a given time frame in order to avoid getting rate limited. + +
+ +All code can be found in the source directory: `📄 src` + +
+ +Most of the work happens in the constructor of the queue where all initialisation is kicked off. This will trigger as soon as a Queue is instantiated. + +### 📄 src/queue.ts +```typescript +⬜ 18 constructor(onProcess: WorkerFunction, items: T[], dailyRateLimit: number, sourceQueueOnEveryRun = false) { +⬜ 19 this.queue = items; +⬜ 20 this.snapshot = items; +🟩 21 this.onProcess = onProcess; +🟩 22 this.sourceQueueOnEveryRun = sourceQueueOnEveryRun; +🟩 23 this.dailyRateLimit = dailyRateLimit; +🟩 24 this.start(); +⬜ 25 } +⬜ 26 +⬜ 27 private start = () => { +``` + +
+ +## Adding Tests + +
+ +You can add tests to the `📄 src` folder. Make sure to suffix them with \`\*.test.ts\`. + +
+ +## Important Bits + +
+ +All code is packaged from lib. Make sure you build the package first before distributing it. + +### 📄 package.json +```json +⬜ 17 "typescript": "^4.3.4" +⬜ 18 }, +⬜ 19 "files": [ +🟩 20 "lib/**/*" +⬜ 21 ] +⬜ 22 } +⬜ 23 +``` + +
+ +The output folder is set up in the tsconfig file + +### 📄 tsconfig.json +```json +⬜ 14 // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ +⬜ 15 // "sourceMap": true, /* Generates corresponding '.map' file. */ +⬜ 16 // "outFile": "./", /* Concatenate and emit output to single file. */ +🟩 17 "outDir": "./lib", /* Redirect output structure to the directory. */ +⬜ 18 // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ +⬜ 19 // "composite": true, /* Enable project compilation */ +⬜ 20 // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ +``` + +
+ +This file was generated by Swimm. [Click here to view it in the app](https://app.swimm.io/repos/Z2l0aHViJTNBJTNBcmF0ZS1saW1pdC1xdWV1ZSUzQSUzQUZyZWRkaXh4/docs/3c009). \ No newline at end of file diff --git a/.swm/swimm.json b/.swm/swimm.json new file mode 100644 index 0000000..a0d9033 --- /dev/null +++ b/.swm/swimm.json @@ -0,0 +1,6 @@ +{ + "repo_id": "Z2l0aHViJTNBJTNBcmF0ZS1saW1pdC1xdWV1ZSUzQSUzQUZyZWRkaXh4", + "configuration": { + "swmd": true + } +}