Add docstrings

This commit is contained in:
Ray Schamp 2017-05-11 01:57:16 -04:00
parent a00562cbca
commit 15b6a16af3
2 changed files with 19 additions and 0 deletions

View file

@ -70,6 +70,12 @@ class BuiltinHelper extends Helper {
}
}
/**
* Synchronously fetch a cached asset for a given asset id. Returns null if not found.
* @param {string} assetId - The id for the asset to fetch.
* @returns {?Asset} The asset for assetId, if it exists.
*/
get (assetId) {
let asset = null;
if (this.assets.hasOwnProperty(assetId)) {
@ -80,6 +86,14 @@ class BuiltinHelper extends Helper {
return asset;
}
/**
* Cache an asset for future lookups by ID.
* @param {AssetType} assetType - The type of the asset to cache.
* @param {DataFormat} dataFormat - The dataFormat of the data for the cached asset.
* @param {Buffer} data - The data for the cached asset.
* @param {string} id - The id for the cached asset.
* @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
*/
cache (assetType, dataFormat, data, id) {
if (!dataFormat) throw new Error('Data cached without specifying its format');
if (id) {

View file

@ -49,6 +49,11 @@ class ScratchStorage {
return AssetType;
}
/**
* Synchronously fetch a cached asset from built-in storage. Assets are cached when they are loaded.
* @param {string} assetId - The id of the asset to fetch.
* @returns {?Asset} The asset, if it exists.
*/
get (assetId) {
return this.builtinHelper.get(assetId);
}