Skip to content

Commit 171cff5

Browse files
author
Ray Schamp
committed
feat(api): Expose builtinHelper.cache to storage API
1 parent 99115ae commit 171cff5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ScratchStorage.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,18 @@ class ScratchStorage {
6868
return this.builtinHelper.get(assetId);
6969
}
7070

71+
/**
72+
* Cache an asset for future lookups by ID.
73+
* @param {AssetType} assetType - The type of the asset to cache.
74+
* @param {DataFormat} dataFormat - The dataFormat of the data for the cached asset.
75+
* @param {Buffer} data - The data for the cached asset.
76+
* @param {string} id - The id for the cached asset.
77+
* @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
78+
*/
79+
cache (assetType, dataFormat, data, id) {
80+
return this.builtinHelper.cache(assetType, dataFormat, data, id);
81+
}
82+
7183
/**
7284
* Register a web-based source for assets. Sources will be checked in order of registration.
7385
* @param {Array.<AssetType>} types - The types of asset provided by this source.

0 commit comments

Comments
 (0)