Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscdn committed Oct 31, 2023
1 parent 58010b0 commit 6e66132
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ This is functionally equivalent to:

```js
const results = semaphore.canAcquire([key] ?
await semaphore.request(fn, [key]) :
null
await semaphore.request(fn, [key]) :
null
```
This is useful in situations when only one instance of a function block should run at a time, while discarding other attempts to execute the block. E.g., a button is repeatedly clicked.
Expand Down Expand Up @@ -178,17 +178,17 @@ Alternatively, this can be accomplished with the `request` function:
```js
async function downloadAndSave(url) {

return semaphore.request(() => {
const filePath = urlToFilePath(url)
return semaphore.request(() => {
const filePath = urlToFilePath(url)

if (await pathExists(filePath)) {
// the file is on disk, so no action is required
} else {
await downloadAndSaveToFilepath(url, filePath)
}
if (await pathExists(filePath)) {
// the file is on disk, so no action is required
} else {
await downloadAndSaveToFilepath(url, filePath)
}

return filePath
}, url)
return filePath
}, url)

}
```
Expand Down

0 comments on commit 6e66132

Please sign in to comment.