Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexandershushunov/invoke-in-sequence-only-the-first-and-last
https://github.com/alexandershushunov/invoke-in-sequence-only-the-first-and-last
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexandershushunov/invoke-in-sequence-only-the-first-and-last
- Owner: AlexanderShushunov
- Created: 2024-06-08T21:39:27.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-09T00:33:35.000Z (7 months ago)
- Last Synced: 2024-06-09T22:49:16.570Z (7 months ago)
- Language: TypeScript
- Size: 163 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Invoke In Sequence Only The First And Last
This high-order function wraps an asynchronous function to
ensure controlled execution. When the wrapped function
is invoked, it starts executing immediately if it's the
first call. However, if the function is called multiple
times before the first execution completes, only the last
call will be executed once the first execution finishes.
This mechanism ensures that no parallel executions occur,
and redundant calls are ignored until the initial
execution is complete.```typescript
async function base(params): Promise {
...
}
const wrapped = invokeInSequenceOnlyTheFirstAndLast(base)
```![diagram.png](diagram.png)