Skip to content

Commit 5db3813

Browse files
committed
chore: unnecessary return await function found
1 parent aa35d98 commit 5db3813

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

src/engine/Engine.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,15 @@ class Engine {
283283
const hydrateModelList = async (property, modelToProcess, name) => {
284284
const subModelClass = getSubModelClass(modelToProcess, name, true);
285285

286-
const newModelList = await Promise.all(property.map(async subModel => {
286+
const newModelList = await Promise.all(property.map(subModel => {
287287
if (hydratedModels[subModel.id]) {
288288
return hydratedModels[subModel.id];
289289
}
290290

291-
return await this.get(subModelClass, subModel.id);
291+
return this.get(subModelClass, subModel.id);
292292
}));
293293

294-
return await Promise.all(newModelList.map(async subModel => {
294+
return Promise.all(newModelList.map(async subModel => {
295295
if (hydratedModels[subModel.id]) {
296296
return hydratedModels[subModel.id];
297297
}
@@ -312,7 +312,7 @@ class Engine {
312312
return isArray ? constructorField._items : constructorField;
313313
}
314314

315-
return await hydrateModel(await this.get(model.constructor, model.id));
315+
return hydrateModel(await this.get(model.constructor, model.id));
316316
}
317317

318318
/**

src/engine/HTTPEngine.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class HTTPEngine extends Engine {
126126
*
127127
* @throws {HTTPRequestFailedError} Thrown if the fetch request fails.
128128
*/
129-
static async getById(id) {
129+
static getById(id) {
130130
this.checkConfiguration();
131131

132132
const url = new URL([
@@ -135,7 +135,7 @@ class HTTPEngine extends Engine {
135135
`${id}.json`,
136136
].filter(e => Boolean(e)).join('/'));
137137

138-
return await this._processFetch(url, this._getReadOptions());
138+
return this._processFetch(url, this._getReadOptions());
139139
}
140140

141141
/**
@@ -177,7 +177,7 @@ class HTTPEngine extends Engine {
177177
'_index.json',
178178
].filter(e => Boolean(e)).join('/'));
179179

180-
return await this._processFetch(url, {
180+
return this._processFetch(url, {
181181
...this._getWriteOptions(),
182182
body: JSON.stringify({
183183
...await this.getIndex(location),
@@ -199,15 +199,15 @@ class HTTPEngine extends Engine {
199199
* @param {Model.constructor?} model - The model in the host where the index is stored.
200200
* @returns {Promise<Object>} The index data in JSON format.
201201
*/
202-
static async getIndex(model) {
202+
static getIndex(model) {
203203
const url = new URL([
204204
this.configuration.host,
205205
this.configuration.prefix,
206206
model?.toString(),
207207
'_index.json',
208208
].filter(e => Boolean(e)).join('/'));
209209

210-
return await this._processFetch(url, this._getReadOptions(), {});
210+
return this._processFetch(url, this._getReadOptions(), {});
211211
}
212212

213213
/**
@@ -216,15 +216,15 @@ class HTTPEngine extends Engine {
216216
* @param {Model.constructor} model - The model whose compiled search index to retrieve.
217217
* @returns {Promise<Object>} The compiled search index in JSON format.
218218
*/
219-
static async getSearchIndexCompiled(model) {
219+
static getSearchIndexCompiled(model) {
220220
const url = new URL([
221221
this.configuration.host,
222222
this.configuration.prefix,
223223
model.toString(),
224224
'_search_index.json',
225225
].join('/'));
226226

227-
return await this._processFetch(url, this._getReadOptions());
227+
return this._processFetch(url, this._getReadOptions());
228228
}
229229

230230
/**
@@ -233,15 +233,15 @@ class HTTPEngine extends Engine {
233233
* @param {Model.constructor} model - The model whose raw search index to retrieve.
234234
* @returns {Promise<Object>} The raw search index in JSON format, or an empty object if not found.
235235
*/
236-
static async getSearchIndexRaw(model) {
236+
static getSearchIndexRaw(model) {
237237
const url = new URL([
238238
this.configuration.host,
239239
this.configuration.prefix,
240240
model.toString(),
241241
'_search_index_raw.json',
242242
].join('/'));
243243

244-
return await this._processFetch(url, this._getReadOptions()).catch(() => ({}));
244+
return this._processFetch(url, this._getReadOptions()).catch(() => ({}));
245245
}
246246

247247
/**
@@ -253,7 +253,7 @@ class HTTPEngine extends Engine {
253253
*
254254
* @throws {HTTPRequestFailedError} Thrown if the PUT request fails.
255255
*/
256-
static async putSearchIndexCompiled(model, compiledIndex) {
256+
static putSearchIndexCompiled(model, compiledIndex) {
257257
const url = new URL([
258258
this.configuration.host,
259259
this.configuration.prefix,
@@ -276,15 +276,15 @@ class HTTPEngine extends Engine {
276276
*
277277
* @throws {HTTPRequestFailedError} Thrown if the PUT request fails.
278278
*/
279-
static async putSearchIndexRaw(model, rawIndex) {
279+
static putSearchIndexRaw(model, rawIndex) {
280280
const url = new URL([
281281
this.configuration.host,
282282
this.configuration.prefix,
283283
model.toString(),
284284
'_search_index_raw.json',
285285
].filter(e => Boolean(e)).join('/'));
286286

287-
return await this._processFetch(url, {
287+
return this._processFetch(url, {
288288
...this._getWriteOptions(),
289289
body: JSON.stringify(rawIndex),
290290
});

src/engine/S3Engine.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ class S3Engine extends Engine {
153153
* @param {Model.constructor} model - The model whose search index to retrieve.
154154
* @returns {Promise<Object>} The compiled search index.
155155
*/
156-
static async getSearchIndexCompiled(model) {
157-
return await this.configuration.client.send(new GetObjectCommand({
158-
Key: [this.configuration.prefix, model.name, '_search_index.json'].join('/'),
156+
static getSearchIndexCompiled(model) {
157+
return this.configuration.client.send(new GetObjectCommand({
158+
Key: [this.configuration.prefix, model.toString(), '_search_index.json'].join('/'),
159159
Bucket: this.configuration.bucket,
160160
})).then(data => data.Body.transformToString())
161161
.then(JSON.parse);
@@ -167,8 +167,8 @@ class S3Engine extends Engine {
167167
* @param {Model.constructor} model - The model whose raw search index to retrieve.
168168
* @returns {Promise<Object>} The raw search index, or an empty object if not found.
169169
*/
170-
static async getSearchIndexRaw(model) {
171-
return await this.configuration.client.send(new GetObjectCommand({
170+
static getSearchIndexRaw(model) {
171+
return this.configuration.client.send(new GetObjectCommand({
172172
Key: [this.configuration.prefix, model.toString(), '_search_index_raw.json'].join('/'),
173173
Bucket: this.configuration.bucket,
174174
})).then(data => data.Body.transformToString())

0 commit comments

Comments
 (0)