(prefix: string)
| 1009 | |
| 1010 | // Define an inner async recursion |
| 1011 | async function recurse(prefix: string) { |
| 1012 | let cursor; |
| 1013 | do { |
| 1014 | // 1. List one page of prefixes under `prefix` |
| 1015 | const listResult = await bucket.list({ prefix, delimiter: "/", cursor }); |
| 1016 | const { delimitedPrefixes = [], truncated } = listResult; |
| 1017 | |
| 1018 | // 2. For each child prefix, record it and recurse into it |
| 1019 | // Ensure the child prefix ends with '/' before adding/recursing |
| 1020 | for (const childPrefix of delimitedPrefixes) { |
| 1021 | const ensuredChildPrefix = childPrefix.endsWith("/") |
| 1022 | ? childPrefix |
| 1023 | : childPrefix + "/"; |
| 1024 | all.push(ensuredChildPrefix); |
| 1025 | await recurse(ensuredChildPrefix); |
| 1026 | } |
| 1027 | cursor = truncated ? listResult.cursor : undefined; |
| 1028 | } while (cursor); |
| 1029 | } |
| 1030 | |
| 1031 | // Kick off recursion |
| 1032 | await recurse(startPrefix); |
no test coverage detected