Comparing version 0.32.0 to 0.33.0
{ | ||
"name": "dcmjs", | ||
"version": "0.32.0", | ||
"version": "0.33.0", | ||
"description": "Javascript implementation of DICOM manipulation", | ||
@@ -5,0 +5,0 @@ "main": "build/dcmjs.js", |
@@ -58,5 +58,5 @@ import fs from "fs"; | ||
async function getZippedTestDataset(url, filename, unpackDirectory) { | ||
var dir = ensureTestDataDir(); | ||
var targetPath = path.join(dir, filename); | ||
var unpackPath = path.join(dir, unpackDirectory); | ||
const dir = ensureTestDataDir(); | ||
const targetPath = path.join(dir, filename); | ||
const unpackPath = path.join(dir, unpackDirectory); | ||
if (!fs.existsSync(unpackPath)) { | ||
@@ -69,8 +69,17 @@ await downloadToFile(url, targetPath); | ||
/** | ||
* Stores the required downloads to prevent async reading before download completed. | ||
*/ | ||
const asyncDownloadMap = new Map(); | ||
async function getTestDataset(url, filename) { | ||
var dir = ensureTestDataDir(); | ||
var targetPath = path.join(dir, filename); | ||
if (!fs.existsSync(targetPath)) { | ||
await downloadToFile(url, targetPath); | ||
const dir = ensureTestDataDir(); | ||
const targetPath = path.join(dir, filename); | ||
let filePromise = asyncDownloadMap.get(targetPath); | ||
if (!filePromise && !fs.existsSync(targetPath)) { | ||
filePromise = downloadToFile(url, targetPath); | ||
asyncDownloadMap.set(targetPath,filePromise); | ||
} | ||
// This returns immediately if filePromise is undefined - eg if the file already downloaded. | ||
await filePromise; | ||
return targetPath; | ||
@@ -77,0 +86,0 @@ } |
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
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
12432389
58087