@newmo/graphql-codegen-fake-server-client 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,24 +17,24 @@ export type CreateFakeClientOptions = {
17
17
 
18
18
  // Request queue implementation for rate limiting
19
19
  class RequestQueue {
20
- private queue: Array<() => Promise<any>> = [];
21
- private running = 0;
22
- private maxConcurrent: number = 10; // Reduced default for better stability
23
- private requestDelay: number = 10; // Small delay to prevent overwhelming the server
24
- private lastRequestTime = 0;
20
+ #queue: Array<() => Promise<unknown>> = [];
21
+ #running = 0;
22
+ #maxConcurrent: number = 10; // Reduced default for better stability
23
+ #requestDelay: number = 10; // Small delay to prevent overwhelming the server
24
+ #lastRequestTime = 0;
25
25
 
26
26
  async add<T>(fn: () => Promise<T>): Promise<T> {
27
27
  return new Promise((resolve, reject) => {
28
- this.queue.push(async () => {
28
+ this.#queue.push(async () => {
29
29
  try {
30
30
  // Apply request delay if configured
31
- if (this.requestDelay > 0) {
31
+ if (this.#requestDelay > 0) {
32
32
  const now = Date.now();
33
- const timeSinceLastRequest = now - this.lastRequestTime;
34
- if (timeSinceLastRequest < this.requestDelay) {
35
- await new Promise(r => setTimeout(r, this.requestDelay - timeSinceLastRequest));
33
+ const timeSinceLastRequest = now - this.#lastRequestTime;
34
+ if (timeSinceLastRequest < this.#requestDelay) {
35
+ await new Promise(r => setTimeout(r, this.#requestDelay - timeSinceLastRequest));
36
36
  }
37
- this.lastRequestTime = Date.now();
37
+ this.#lastRequestTime = Date.now();
38
38
  }
39
39
 
40
40
  const result = await fn();
@@ -43,21 +43,21 @@ class RequestQueue {
43
43
  reject(error);
44
44
  }
45
45
  });
46
- this.process();
46
+ this.#process();
47
47
  });
48
48
  }
49
49
 
50
- private async process() {
51
- if (this.running >= this.maxConcurrent || this.queue.length === 0) {
50
+ async #process() {
51
+ if (this.#running >= this.#maxConcurrent || this.#queue.length === 0) {
52
52
  return;
53
53
  }
54
54
 
55
- this.running++;
56
- const fn = this.queue.shift();
55
+ this.#running++;
56
+ const fn = this.#queue.shift();
57
57
  if (fn) {
58
58
  await fn();
59
- this.running--;
60
- this.process();
59
+ this.#running--;
60
+ this.#process();
61
61
  }
62
62
  }
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newmo/graphql-codegen-fake-server-client",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "private": false,
5
5
  "description": "GraphQL Codegen plugin for generating a fake server client",
6
6
  "keywords": [
@@ -62,5 +62,5 @@
62
62
  "access": "public",
63
63
  "registry": "https://registry.npmjs.org/"
64
64
  },
65
- "gitHead": "9f78beca5016a585f3de1ca2cc0a3ccb24fd743e"
65
+ "gitHead": "9c06e9666ff8ad8d4ef950c26b5ead905c26ff4e"
66
66
  }
@@ -14,24 +14,24 @@ export type CreateFakeClientOptions = {
14
14
 
15
15
  // Request queue implementation for rate limiting
16
16
  class RequestQueue {
17
- private queue: Array<() => Promise<any>> = [];
18
- private running = 0;
19
- private maxConcurrent: number = 10; // Reduced default for better stability
20
- private requestDelay: number = 10; // Small delay to prevent overwhelming the server
21
- private lastRequestTime = 0;
17
+ #queue: Array<() => Promise<unknown>> = [];
18
+ #running = 0;
19
+ #maxConcurrent: number = 10; // Reduced default for better stability
20
+ #requestDelay: number = 10; // Small delay to prevent overwhelming the server
21
+ #lastRequestTime = 0;
22
22
 
23
23
  async add<T>(fn: () => Promise<T>): Promise<T> {
24
24
  return new Promise((resolve, reject) => {
25
- this.queue.push(async () => {
25
+ this.#queue.push(async () => {
26
26
  try {
27
27
  // Apply request delay if configured
28
- if (this.requestDelay > 0) {
28
+ if (this.#requestDelay > 0) {
29
29
  const now = Date.now();
30
- const timeSinceLastRequest = now - this.lastRequestTime;
31
- if (timeSinceLastRequest < this.requestDelay) {
32
- await new Promise(r => setTimeout(r, this.requestDelay - timeSinceLastRequest));
30
+ const timeSinceLastRequest = now - this.#lastRequestTime;
31
+ if (timeSinceLastRequest < this.#requestDelay) {
32
+ await new Promise(r => setTimeout(r, this.#requestDelay - timeSinceLastRequest));
33
33
  }
34
- this.lastRequestTime = Date.now();
34
+ this.#lastRequestTime = Date.now();
35
35
  }
36
36
 
37
37
  const result = await fn();
@@ -40,21 +40,21 @@ class RequestQueue {
40
40
  reject(error);
41
41
  }
42
42
  });
43
- this.process();
43
+ this.#process();
44
44
  });
45
45
  }
46
46
 
47
- private async process() {
48
- if (this.running >= this.maxConcurrent || this.queue.length === 0) {
47
+ async #process() {
48
+ if (this.#running >= this.#maxConcurrent || this.#queue.length === 0) {
49
49
  return;
50
50
  }
51
51
 
52
- this.running++;
53
- const fn = this.queue.shift();
52
+ this.#running++;
53
+ const fn = this.#queue.shift();
54
54
  if (fn) {
55
55
  await fn();
56
- this.running--;
57
- this.process();
56
+ this.#running--;
57
+ this.#process();
58
58
  }
59
59
  }
60
60
  }