Skip to content

Commit

Permalink
chore: unnecessary return await function found
Browse files Browse the repository at this point in the history
  • Loading branch information
acodeninja committed Sep 30, 2024
1 parent aa35d98 commit 5db3813
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/engine/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,15 @@ class Engine {
const hydrateModelList = async (property, modelToProcess, name) => {
const subModelClass = getSubModelClass(modelToProcess, name, true);

const newModelList = await Promise.all(property.map(async subModel => {
const newModelList = await Promise.all(property.map(subModel => {
if (hydratedModels[subModel.id]) {
return hydratedModels[subModel.id];
}

return await this.get(subModelClass, subModel.id);
return this.get(subModelClass, subModel.id);
}));

return await Promise.all(newModelList.map(async subModel => {
return Promise.all(newModelList.map(async subModel => {
if (hydratedModels[subModel.id]) {
return hydratedModels[subModel.id];
}
Expand All @@ -312,7 +312,7 @@ class Engine {
return isArray ? constructorField._items : constructorField;
}

return await hydrateModel(await this.get(model.constructor, model.id));
return hydrateModel(await this.get(model.constructor, model.id));
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/engine/HTTPEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class HTTPEngine extends Engine {
*
* @throws {HTTPRequestFailedError} Thrown if the fetch request fails.
*/
static async getById(id) {
static getById(id) {
this.checkConfiguration();

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

return await this._processFetch(url, this._getReadOptions());
return this._processFetch(url, this._getReadOptions());
}

/**
Expand Down Expand Up @@ -177,7 +177,7 @@ class HTTPEngine extends Engine {
'_index.json',
].filter(e => Boolean(e)).join('/'));

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

return await this._processFetch(url, this._getReadOptions(), {});
return this._processFetch(url, this._getReadOptions(), {});
}

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

return await this._processFetch(url, this._getReadOptions());
return this._processFetch(url, this._getReadOptions());
}

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

return await this._processFetch(url, this._getReadOptions()).catch(() => ({}));
return this._processFetch(url, this._getReadOptions()).catch(() => ({}));
}

/**
Expand All @@ -253,7 +253,7 @@ class HTTPEngine extends Engine {
*
* @throws {HTTPRequestFailedError} Thrown if the PUT request fails.
*/
static async putSearchIndexCompiled(model, compiledIndex) {
static putSearchIndexCompiled(model, compiledIndex) {
const url = new URL([
this.configuration.host,
this.configuration.prefix,
Expand All @@ -276,15 +276,15 @@ class HTTPEngine extends Engine {
*
* @throws {HTTPRequestFailedError} Thrown if the PUT request fails.
*/
static async putSearchIndexRaw(model, rawIndex) {
static putSearchIndexRaw(model, rawIndex) {
const url = new URL([
this.configuration.host,
this.configuration.prefix,
model.toString(),
'_search_index_raw.json',
].filter(e => Boolean(e)).join('/'));

return await this._processFetch(url, {
return this._processFetch(url, {
...this._getWriteOptions(),
body: JSON.stringify(rawIndex),
});
Expand Down
10 changes: 5 additions & 5 deletions src/engine/S3Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ class S3Engine extends Engine {
* @param {Model.constructor} model - The model whose search index to retrieve.
* @returns {Promise<Object>} The compiled search index.
*/
static async getSearchIndexCompiled(model) {
return await this.configuration.client.send(new GetObjectCommand({
Key: [this.configuration.prefix, model.name, '_search_index.json'].join('/'),
static getSearchIndexCompiled(model) {
return this.configuration.client.send(new GetObjectCommand({
Key: [this.configuration.prefix, model.toString(), '_search_index.json'].join('/'),
Bucket: this.configuration.bucket,
})).then(data => data.Body.transformToString())
.then(JSON.parse);
Expand All @@ -167,8 +167,8 @@ class S3Engine extends Engine {
* @param {Model.constructor} model - The model whose raw search index to retrieve.
* @returns {Promise<Object>} The raw search index, or an empty object if not found.
*/
static async getSearchIndexRaw(model) {
return await this.configuration.client.send(new GetObjectCommand({
static getSearchIndexRaw(model) {
return this.configuration.client.send(new GetObjectCommand({
Key: [this.configuration.prefix, model.toString(), '_search_index_raw.json'].join('/'),
Bucket: this.configuration.bucket,
})).then(data => data.Body.transformToString())
Expand Down

0 comments on commit 5db3813

Please sign in to comment.