@@ -221,7 +221,10 @@ executable, users can retrieve the assets using the [`sea.getAsset()`][] and
221221The single-executable application can access the assets as follows:
222222
223223```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' ]
225228// Returns a copy of the data in an ArrayBuffer.
226229const image = getAsset(' a.jpg' );
227230// Returns a string decoded from the asset as UTF8.
@@ -232,8 +235,8 @@ const blob = getAssetAsBlob('a.jpg');
232235const raw = getRawAsset(' a.jpg' );
233236```
234237
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.
237240
238241### Startup snapshot support
239242
@@ -429,6 +432,19 @@ writes to the returned array buffer is likely to result in a crash.
429432 `assets` field in the single-executable application configuration.
430433* Returns: {ArrayBuffer}
431434
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+
432448### `require(id)` in the injected main script is not file based
433449
434450`require()` in the injected main script is not the same as the [`require()`][]
@@ -503,6 +519,7 @@ to help us document them.
503519[`require.main`]: modules.md#accessing-the-main-module
504520[`sea.getAsset()`]: #seagetassetkey-encoding
505521[`sea.getAssetAsBlob()`]: #seagetassetasblobkey-options
522+ [`sea.getAssetKeys()`]: #seagetassetkeys
506523[`sea.getRawAsset()`]: #seagetrawassetkey
507524[`v8.startupSnapshot.setDeserializeMainFunction()`]: v8.md#v8startupsnapshotsetdeserializemainfunctioncallback-data
508525[`v8.startupSnapshot` API]: v8.md#startup-snapshot-api
0 commit comments