Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
MarlonPassos-git committed Nov 23, 2024
1 parent 73bae96 commit 4f5a4bd
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 25 deletions.
6 changes: 3 additions & 3 deletions scripts/benchmarks/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"type": "module",
"private": true,
"scripts": {
"test": "vitest"
},
"exports": {
"./*": "./src/*"
},
"scripts": {
"test": "vitest"
},
"dependencies": {
"@babel/parser": "^7.25.3",
"@babel/traverse": "^7.25.3",
Expand Down
2 changes: 1 addition & 1 deletion scripts/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"exports": {
"./*": "./src/*"
}
}
}
2 changes: 1 addition & 1 deletion scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"type": "module",
"private": true
}
}
10 changes: 5 additions & 5 deletions scripts/radashi-db/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"type": "module",
"private": true,
"dependencies": {
"@supabase/supabase-js": "^2.45.0",
"algoliasearch": "^4.24.0",
"execa": "^9.5.1"
},
"exports": {
"./*": "./src/*"
},
"scripts": {
"gen-types": "node --experimental-strip-types ./gen-types.ts"
},
"dependencies": {
"@supabase/supabase-js": "^2.45.0",
"algoliasearch": "^4.24.0",
"execa": "^9.5.1"
}
}
4 changes: 3 additions & 1 deletion src/async/parallel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ export async function parallel<T, K>(
}

const queues = Promise.all(
list(1, clamp(options.limit, 1, array.length)).map(() => new Promise(processor)),
list(1, clamp(options.limit, 1, array.length)).map(
() => new Promise(processor),
),
)

let signalPromise: Promise<never> | undefined
Expand Down
6 changes: 3 additions & 3 deletions src/async/retry.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { sleep, tryit } from 'radashi'

type AbortSignal = {
throwIfAborted(): void
}
type AbortSignal = {
throwIfAborted(): void
}

export type RetryOptions = {
times?: number
Expand Down
34 changes: 23 additions & 11 deletions tests/async/parallel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,39 @@ describe('parallel', () => {

test('should run only one parallel function when a negative number is passed', async () => {
const { tracking, func } = makeProgressTracker()
await _.parallel({
limit: -1,
}, _.list(1, 10), func)
await _.parallel(
{
limit: -1,
},
_.list(1, 10),
func,
)
expect(Math.max(...tracking)).toBe(1)
expect(tracking).toEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
})

test('should run only one parallel function when 0 is passed', async () => {
const { tracking, func } = makeProgressTracker()
await _.parallel({
limit: 0,
}, _.list(1, 10), func)
await _.parallel(
{
limit: 0,
},
_.list(1, 10),
func,
)
expect(Math.max(...tracking)).toBe(1)
expect(tracking).toEqual([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])
})

test('should run the same number of parallel functions as the array size when Infinity is passed', async () => {
const { tracking, func } = makeProgressTracker()
await _.parallel({
limit: Number.POSITIVE_INFINITY,
}, _.list(1, 10), func)
await _.parallel(
{
limit: Number.POSITIVE_INFINITY,
},
_.list(1, 10),
func,
)
expect(Math.max(...tracking)).toBe(10)
expect(tracking).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
})
Expand Down

0 comments on commit 4f5a4bd

Please sign in to comment.