@absolutejs/voice 0.0.22-beta.429 → 0.0.22-beta.430
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.
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28814,7 +28814,8 @@ var removeRecentJsonFileIndexEntry = async (directory, path) => {
|
|
|
28814
28814
|
};
|
|
28815
28815
|
var isDefined = (value) => value !== undefined;
|
|
28816
28816
|
var readRecentJsonFiles = async (directory, limit) => {
|
|
28817
|
-
const
|
|
28817
|
+
const indexedFiles = await readRecentJsonFileIndex(directory);
|
|
28818
|
+
const files = indexedFiles.length >= limit ? indexedFiles.map((entry) => entry.path) : await listRecentJsonFiles(directory, limit);
|
|
28818
28819
|
const missingPaths = new Set;
|
|
28819
28820
|
const readRecentFile = async (file) => {
|
|
28820
28821
|
try {
|
|
@@ -28827,11 +28828,16 @@ var readRecentJsonFiles = async (directory, limit) => {
|
|
|
28827
28828
|
throw error;
|
|
28828
28829
|
}
|
|
28829
28830
|
};
|
|
28830
|
-
const
|
|
28831
|
+
const existingRecords = [];
|
|
28832
|
+
for (let index = 0;index < files.length && existingRecords.length < limit; ) {
|
|
28833
|
+
const window = files.slice(index, index + limit - existingRecords.length);
|
|
28834
|
+
const records = await Promise.all(window.map((file) => readRecentFile(file)));
|
|
28835
|
+
existingRecords.push(...records.filter(isDefined));
|
|
28836
|
+
index += window.length;
|
|
28837
|
+
}
|
|
28831
28838
|
if (missingPaths.size > 0) {
|
|
28832
28839
|
await writeRecentJsonFileIndex(directory, (await readRecentJsonFileIndex(directory)).filter((entry) => !missingPaths.has(entry.path)));
|
|
28833
28840
|
}
|
|
28834
|
-
const existingRecords = records.filter(isDefined);
|
|
28835
28841
|
if (existingRecords.length === limit || missingPaths.size === 0) {
|
|
28836
28842
|
return existingRecords;
|
|
28837
28843
|
}
|