Skip to content

Commit 88a939d

Browse files
author
Ray Schamp
committed
fix: address review feedback
Thanks @kchadha and @cwillisf!
1 parent 13def4e commit 88a939d

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

src/BuiltinHelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ class BuiltinHelper extends Helper {
113113
* @param {AssetType} assetType - The type of the asset to cache.
114114
* @param {DataFormat} dataFormat - The dataFormat of the data for the cached asset.
115115
* @param {Buffer} data - The data for the cached asset.
116-
* @param {string} id - The id for the cached asset.
116+
* @param {(string|number)} id - The id for the cached asset.
117117
* @returns {string} The calculated id of the cached asset, or the supplied id if the asset is mutable.
118118
*/
119119
store (assetType, dataFormat, data, id) {
120120
if (!dataFormat) throw new Error('Data cached without specifying its format');
121-
if (id !== null && typeof id !== 'undefined') {
121+
if (id !== '' && id !== null && typeof id !== 'undefined') {
122122
if (this.assets.hasOwnProperty(id) && assetType.immutable) return id;
123123
} else if (assetType.immutable) {
124124
id = md5(data);

src/ScratchStorage.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ class ScratchStorage {
187187
/**
188188
* Store an asset by type & ID.
189189
* @param {AssetType} assetType - The type of asset to fetch. This also determines which asset store to use.
190-
* @param {DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
191-
* @param {DataFormat} [data] - Optional: store this data, rather than the data in the asset
192-
* @param {?string} assetId - The ID of the asset to fetch: a project ID, MD5, etc.
193-
* @return {Promise.<id, title>} A promise for asset metadata
190+
* @param {?DataFormat} [dataFormat] - Optional: load this format instead of the AssetType's default.
191+
* @param {Buffer} data - Data to store for the asset
192+
* @param {?string} [assetId] - The ID of the asset to fetch: a project ID, MD5, etc.
193+
* @return {Promise.<object>} A promise for asset metadata
194194
*/
195195
store (assetType, dataFormat, data, assetId) {
196196
dataFormat = dataFormat || assetType.runtimeFormat;

src/WebHelper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class WebHelper extends Helper {
3939
}
4040

4141
/**
42-
* Register a web-based source for assets. Sources will be checked in order of registration.
43-
* @param {Array.<AssetType>} types - The types of asset provided by this source.
42+
* Register a web-based store for assets. Sources will be checked in order of registration.
43+
* @param {Array.<AssetType>} types - The types of asset provided by this store.
4444
* @param {UrlFunction} getFunction - A function which computes a GET URL for an Asset
4545
* @param {UrlFunction} createFunction - A function which computes a POST URL for an Asset
4646
* @param {UrlFunction} updateFunction - A function which computes a PUT URL for an Asset
@@ -130,9 +130,9 @@ class WebHelper extends Helper {
130130
store (assetType, dataFormat, data, assetId) {
131131
const asset = new Asset(assetType, assetId, dataFormat);
132132
// If we have an asset id, we should update, otherwise create to get an id
133-
const create = assetId === null || typeof assetId === 'undefined';
133+
const create = assetId !== '' || assetId === null || typeof assetId === 'undefined';
134134

135-
// Use the first source with the appropriate asset type and url function
135+
// Use the first store with the appropriate asset type and url function
136136
const store = this.stores.filter(s =>
137137
// Only use stores for the incoming asset type
138138
s.types.indexOf(assetType.name) !== -1 && (

0 commit comments

Comments
 (0)