open-index/open-npm huggingface dataset:
npm package: @phlegmaticprogrammer/dettle
Description: A tiny fully-featured debounce and throttle implementation.
Latest version: 1.1.0

# Dettle

A tiny fully-featured debounce and throttle implementation.

## Install

```sh
npm install --save dettle
```

## Usage

```ts
import {debounce, throttle} from 'dettle';

const fn = () => console.log ( 'Fired!' );

// Debouncing

const debounced = debounce ( fn, 1000, {
  leading: false,
  maxWait: 3000
});

debounced (); // Schedule function for execution
debounced (); // Re-schedule function for execution

debounced.flush (); // Execute the function immediately, if there's a scheduled execution
debounced.cancel (); // Cancel the scheduled execution

// Throttling
// The API for throttling is basically the same, except that:
// - `maxWait` is set implicitly for you to be equal to the wait time
// - `leading` is `true` by default rather than `false`

const throttled = throttle ( fn, 1000 );

throttled (); // Call the function immediately
throttled (); // Schedule function for execution

throttled.flush (); // Execute the function immediately, if there's a scheduled execution
throttled.cancel (); // Cancel the scheduled execution
```

## License

MIT © Fabio Spampinato
npm package: @phlegmaticprogrammer/promise-make-naked
Description: A simple function that makes a promise that can be resolved or rejected from the outside.
Latest version: 2.2.0

# Promise Make Naked

A simple function that makes a promise that can be resolved or rejected from the outside.

## Install

```sh
npm install --save promise-make-naked
```

## Usage

```ts
import makeNakedPromise from 'promise-make-naked';

// Let's create a naked Promise

const {promise, resolve, reject, isPending, isResolved, isRejected} = makeNakedPromise ();

resolve ( 123 ); // Resolve the promise with the provided value
reject ( new Error () ); // Reject the promise with the provided reason

isPending (); // Check if promise is still pending
isResolved (); // Check if the promise got resolved
isRejected (); // Check if the promise got rejected

// Let's create a naked Promise similarly to how a normal Promise is created

const result = makeNakedPromise.wrap ( ({ promise, resolve, reject, isPending, isResolved, isRejected }) => {

  resolve ( 123 );

});
```

## License

MIT © Fabio Spampinato
npm package: @phlegmaticprogrammer/stubborn-fs
Description: Stubborn versions of Node's fs functions that try really hard to do their job.
Latest version: 1.3.0

# Stubborn FS

Stubborn versions of Node's `fs` functions that try really hard to do their job.

## Install

```sh
npm install --save stubborn-fs
```

## Usage

The following functions are currently provided, if you need others please open an issue.

- `attempt` functions swallow some errors that may occur.
- `retry` functions are executed in a loop until they succeed or the timeout is reached, in which case an error is thrown.

```ts
import fs from 'stubborn-fs';

// Attempt functions (async)

fs.attempt.chmod;
fs.attempt.chown;
fs.attempt.close;
fs.attempt.fsync;
fs.attempt.mkdir;
fs.attempt.realpath;
fs.attempt.stat;
fs.attempt.unlink;

// Attempt functions (sync)

fs.attempt.chmodSync;
fs.attempt.chownSync;
fs.attempt.closeSync;
fs.attempt.existsSync;
fs.attempt.fsyncSync;
fs.attempt.mkdirSync;
fs.attempt.realpathSync;
fs.attempt.statSync;
fs.attempt.unlinkSync;

// Retry functions (async)

fs.retry.close;
fs.retry.fsync;
fs.retry.open;
fs.retry.readFile;
fs.retry.rename;
fs.retry.stat;
fs.retry.write;
fs.retry.writeFile;

// Retry functions (sync)

fs.retry.closeSync;
fs.retry.fsyncSync;
fs.retry.openSync;
fs.retry.readFileSync;
fs.retry.renameSync;
fs.retry.statSync;
fs.retry.writeSync;
fs.retry.writeFileSync;
```

## License

MIT © Fabio Spampinato
npm package: @phlegmaticprogrammer/tiny-readdir
Description: A simple promisified recursive readdir function.
Latest version: 2.8.0

# Tiny Readdir

A simple promisified recursive readdir function.

## Install

```sh
npm install --save tiny-readdir
```

## Usage

```ts
import readdir from 'tiny-readdir';

const aborter = new AbortController ();

const result = await readdir ( '/foo/bar', {
  depth: 20, // Maximum depth to look at
  limit: 1_000_000, // Maximum number of files explored, useful as a stop gap in some edge cases
  followSymlinks: true, // Whether to follow symlinks or not
  ignore: targetPath => /node_modules/.test ( targetPath ), // Function that if returns true will ignore this particular file or a directory and its descendants
  signal: aborter.signal, // Optional abort signal, useful for aborting potentially expensive operations
  onDirents: dirents => console.log ( dirents ) // Optional callback that will be called as soon as new dirents are available, useful for example for discovering ".gitignore" files while searching
});

console.log ( result.directories ); // => Array of absolute paths pointing to directories
console.log ( result.files ); // => Array of absolute paths pointing to files
console.log ( result.symlinks ); // => Array of absolute paths pointing to symlinks

console.log ( result.directoriesNames ); // => Set of directories names found
console.log ( result.filesNames ); // => Set of files name found
console.log ( result.symlinksNames ); // => Set of symlinks names found

console.log ( result.directoriesNamesToPaths ); // => Record of directories names found to their paths
console.log ( result.filesNamesToPaths ); // => Record of files names found to their paths
console.log ( result.symlinksNamesToPaths ); // => Record of symlinks names found to their paths

setTimeout ( () => aborter.abort (), 10000 ); // Aborting if it's going to take longer than 10s
```

## License

MIT © Fabio Spampinato