prismic-javascript
Advanced tools
Comparing version 2.0.3 to 2.1.0
@@ -13,3 +13,3 @@ { | ||
], | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"devDependencies": { | ||
@@ -19,6 +19,7 @@ "chai": "^4.1.1", | ||
"mocha": "^5.2.0", | ||
"nock": "^10.0.6", | ||
"ts-loader": "^4.4.1", | ||
"tslint": "^5.1.0", | ||
"tslint-config-airbnb": "^5.11.1", | ||
"typedoc": "^0.11.1", | ||
"typedoc": "^0.14.2", | ||
"typescript": "^2.3.2", | ||
@@ -25,0 +26,0 @@ "webpack": "^4.12.0", |
@@ -1,6 +0,18 @@ | ||
// Number of maximum simultaneous connections to the prismic server | ||
const MAX_CONNECTIONS: number = 20; | ||
// Number of requests currently running (capped by MAX_CONNECTIONS) | ||
let running: number = 0; | ||
import { Agent as HttpAgent } from 'http'; | ||
import { Agent as HttpsAgent } from 'https'; | ||
// default agent to use see https://nodejs.org/api/http.html#http_class_http_agent for more options | ||
const httpAgent = new HttpAgent({ | ||
keepAlive: true, | ||
maxSockets: 20, | ||
}); | ||
const httpsAgent = new HttpsAgent({ | ||
keepAlive: true, | ||
maxSockets: 20, | ||
}); | ||
function changeAgent(parsedUrl: any) { | ||
return (parsedUrl.protocol === 'http:') ? httpAgent : httpsAgent; | ||
} | ||
interface Task { | ||
@@ -11,5 +23,2 @@ url: string; | ||
// Requests in queue | ||
const queue: Task[] = []; | ||
interface NodeRequestInit extends RequestInit { | ||
@@ -29,2 +38,4 @@ agent?: any; | ||
fetchOptions.agent = options.proxyAgent; | ||
} else { | ||
fetchOptions.agent = changeAgent; | ||
} | ||
@@ -55,19 +66,2 @@ | ||
function processQueue(options: RequestHandlerOption): void { | ||
if (queue.length > 0 && running < MAX_CONNECTIONS) { | ||
running++; | ||
const req = queue.shift(); | ||
if (req) { | ||
fetchRequest(req.url, options, (error, result, xhr, ttl) => { | ||
running--; | ||
req.callback(error, result, xhr, ttl); | ||
processQueue(options); | ||
}); | ||
} | ||
} | ||
} | ||
export type RequestCallback<T> = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void; | ||
@@ -92,5 +86,5 @@ | ||
request<T>(url: string, callback: RequestCallback<T>): void { | ||
queue.push({ url, callback }); | ||
processQueue(this.options); | ||
fetchRequest(url, this.options, callback); | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2373473
85
12507
12
59
64