run npm install to generate a package lock

This commit is contained in:
sashinexists
2024-12-07 13:18:31 +11:00
parent e7d08a91b5
commit 23437d228e
2501 changed files with 290663 additions and 0 deletions

48
node_modules/promise-make-counter/readme.md generated vendored Normal file
View File

@@ -0,0 +1,48 @@
# Promise Make Counter
A simple function that makes a counter-based promise, which can be incremented and decremented, and it resolves once its counter reaches zero.
This is an alternative to creating a promise that waits on many other promises to resolve. You can do that, but creating many promises can be surprisingly slow, instead you could use this package, switch internally to using callbacks-style APIs rather than async/await-style APIs, and just increment the counter at the start of each callback, and decrement it at its end, once its job is done.
## Install
```sh
npm install --save promise-make-counter
```
## Usage
```ts
import fs from 'node:fs';
import makeCounterPromise from 'promise-make-counter';
// Let's create a counter-based promise
const {promise, isPending, increment, decrement} = makeCounterPromise ();
// Now let's do some work that's tracked by our counter-based promise
// It's important to always increment at the start, and decrement at the end
for ( const filePath of filePaths ) {
increment ();
fs.readFile ( filePath, 'utf8', ( error, data ) => {
// Do something here...
decrement ();
});
}
// Let's wait for the counter-based promise to resolve
// This will happen once its internal counter will reach zero
await promise;
```
## License
MIT © Fabio Spampinato