Skip to content

Commit

Permalink
Fix styling after #1616
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali committed Apr 3, 2024
1 parent 9759c35 commit ab5f4ac
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"size": "node scripts/file-size ./dist/bundles/meilisearch.esm.min.js ./dist/bundles/meilisearch.umd.min.js",
"style": "yarn fmt && yarn lint",
"style:fix": "yarn fmt:fix && yarn lint:fix",
"fmt": "prettier -c ./**/*.{js,ts,tsx}",
"fmt:fix": "prettier -w ./**/*.{js,ts,tsx}",
"fmt": "prettier -c ./**/*.{js,ts}",
"fmt:fix": "prettier -w ./**/*.{js,ts}",
"lint": "eslint --ext .js,.ts,.tsx .",
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
"typingsheader": "node scripts/build.js"
Expand Down
6 changes: 1 addition & 5 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/**
* This file only purpose is to execute any build related tasks
*/
/** This file only purpose is to execute any build related tasks */

const { resolve, normalize } = require('path')
const { readFileSync, writeFileSync } = require('fs')
Expand Down Expand Up @@ -28,7 +26,6 @@ function writeDtsHeader() {
}

/**
*
* @param {string} pkgName
* @param {string} version
* @param {string} author
Expand All @@ -49,7 +46,6 @@ function getDtsHeader(pkgName, version, author, repoUrl, tsVersion) {
}

/**
*
* @param {string} path
* @param {string | Blob} data
*/
Expand Down
5 changes: 1 addition & 4 deletions scripts/file-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async function main() {
}

/**
*
* @param {string} pkgName
* @param {string[]} filesOutput
*/
Expand All @@ -49,7 +48,6 @@ function getFormatedOutput(pkgName, filesOutput) {
}

/**
*
* @param {number} size
* @param {string} filename
* @param {'br' | 'gz'} type
Expand All @@ -66,10 +64,9 @@ function formatSize(size, filename, type, raw) {
}

/**
*
* @param {string} code
* @param {string} filename
* @param {boolean} [raw=false]
* @param {boolean} [raw=false] Default is `false`
*/
async function getSizeInfo(code, filename, raw = false) {
const isRaw = raw || code.length < 5000
Expand Down
11 changes: 7 additions & 4 deletions src/http-requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ function constructHostURL(host: string): string {

function cloneAndParseHeaders(headers: HeadersInit): Record<string, string> {
if (Array.isArray(headers)) {
return headers.reduce((acc, headerPair) => {
acc[headerPair[0]] = headerPair[1]
return acc
}, {} as Record<string, string>)
return headers.reduce(
(acc, headerPair) => {
acc[headerPair[0]] = headerPair[1]
return acc
},
{} as Record<string, string>
)
} else if ('has' in headers) {
const clonedHeaders: Record<string, string> = {}
;(headers as Headers).forEach((value, key) => (clonedHeaders[key] = value))
Expand Down
4 changes: 2 additions & 2 deletions src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*/
async search<
D extends Record<string, any> = T,
S extends SearchParams = SearchParams
S extends SearchParams = SearchParams,
>(
query?: string | null,
options?: S,
Expand All @@ -118,7 +118,7 @@ class Index<T extends Record<string, any> = Record<string, any>> {
*/
async searchGet<
D extends Record<string, any> = T,
S extends SearchParams = SearchParams
S extends SearchParams = SearchParams,
>(
query?: string | null,
options?: S,
Expand Down
10 changes: 6 additions & 4 deletions src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ class TaskClient {
while (Date.now() - startingTime < timeOutMs) {
const response = await this.getTask(taskUid)
if (
!([
TaskStatus.TASK_ENQUEUED,
TaskStatus.TASK_PROCESSING,
] as readonly string[]).includes(response.status)
!(
[
TaskStatus.TASK_ENQUEUED,
TaskStatus.TASK_PROCESSING,
] as readonly string[]
).includes(response.status)
)
return response
await sleep(intervalMs)
Expand Down
16 changes: 10 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
/** Removes undefined entries from object */
function removeUndefinedFromObject(obj: Record<string, any>): object {
return Object.entries(obj).reduce((acc, curEntry) => {
const [key, val] = curEntry
if (val !== undefined) acc[key] = val
return acc
}, {} as Record<string, any>)
return Object.entries(obj).reduce(
(acc, curEntry) => {
const [key, val] = curEntry
if (val !== undefined) acc[key] = val
return acc
},
{} as Record<string, any>
)
}

async function sleep(ms: number): Promise<void> {
Expand All @@ -26,7 +29,8 @@ function addTrailingSlash(url: string): string {
}

function validateUuid4(uuid: string): boolean {
const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
const regexExp =
/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi
return regexExp.test(uuid)
}

Expand Down

0 comments on commit ab5f4ac

Please sign in to comment.