@@ -221,7 +221,10 @@ executable, users can retrieve the assets using the [`sea.getAsset()`][] and
221
221
The single-executable application can access the assets as follows:
222
222
223
223
```cjs
224
- const { getAsset, getAssetAsBlob, getRawAsset } = require(' node:sea' );
224
+ const { getAsset, getAssetAsBlob, getRawAsset, getAssetKeys } = require(' node:sea' );
225
+ // Get all asset keys.
226
+ const keys = getAssetKeys();
227
+ console.log(keys); // [' a.jpg' , ' b.txt' ]
225
228
// Returns a copy of the data in an ArrayBuffer.
226
229
const image = getAsset(' a.jpg' );
227
230
// Returns a string decoded from the asset as UTF8.
@@ -232,8 +235,8 @@ const blob = getAssetAsBlob('a.jpg');
232
235
const raw = getRawAsset(' a.jpg' );
233
236
```
234
237
235
- See documentation of the [`sea.getAsset()`][], [`sea.getAssetAsBlob()`][] and [`sea.getRawAsset()`][]
236
- APIs for more information.
238
+ See documentation of the [`sea.getAsset()`][], [`sea.getAssetAsBlob()`][],
239
+ [`sea.getRawAsset()`][] and [`sea.getAssetKeys()`][] APIs for more information.
237
240
238
241
### Startup snapshot support
239
242
@@ -429,6 +432,19 @@ writes to the returned array buffer is likely to result in a crash.
429
432
`assets` field in the single-executable application configuration.
430
433
* Returns: {ArrayBuffer}
431
434
435
+ ### `sea.getAssetKeys()`
436
+
437
+ <!-- YAML
438
+ added: REPLACEME
439
+ -->
440
+
441
+ * Returns {string\[]} An array containing all the keys of the assets
442
+ embedded in the executable. If no assets are embedded, returns an empty array.
443
+
444
+ This method can be used to retrieve an array of all the keys of assets
445
+ embedded into the single-executable application.
446
+ An error is thrown when not running inside a single-executable application.
447
+
432
448
### `require(id)` in the injected main script is not file based
433
449
434
450
`require()` in the injected main script is not the same as the [`require()`][]
@@ -503,6 +519,7 @@ to help us document them.
503
519
[`require.main`]: modules.md#accessing-the-main-module
504
520
[`sea.getAsset()`]: #seagetassetkey-encoding
505
521
[`sea.getAssetAsBlob()`]: #seagetassetasblobkey-options
522
+ [`sea.getAssetKeys()`]: #seagetassetkeys
506
523
[`sea.getRawAsset()`]: #seagetrawassetkey
507
524
[`v8.startupSnapshot.setDeserializeMainFunction()`]: v8.md#v8startupsnapshotsetdeserializemainfunctioncallback-data
508
525
[`v8.startupSnapshot` API]: v8.md#startup-snapshot-api
0 commit comments