open-index/open-npm huggingface dataset:
npm package: @fundwave/fetchq
Description: Queue for fetch requests
Author: The Fundwave Authors
Latest version: 1.2.2

# @fundwave/fetchq

A client-side library that allows you to queue fetch requests.

- Supports ES modules
- Supports CommonJS

## Installation

```sh
npm install @fundwave/fetchq
```

## Initialization

```js
import { FetchQueue } from "@fundwave/fetchq";

const MyFetchQueue = new FetchQueue({ concurrent: 2 });
// returns custom fetch function with queueing enabled.
const fetch = MyFetchQueue.getFetchMethod();
```

## Options

| `Property`        | `Description`                             | `Default Value`                           |
| ----------------- | -------------------------------------     | --------------                            |
| concurrent        | number of concurrent fetch requests       | 3                                         |
| pauseQueueOnInit  | start queue with a paused state           | false                                     |
| pre               | array of configs for pre-fetch-hooks      | []                                        |
| queuingPatterns   | array of regex to queue matching requests | []                                        |
| debug             | set debug mode                            | false                                     |
| keyBuilderParams  | to build a unique key for queue           | ["url", "options.method", "options.body"] |

## Usage

```js
import { FetchQueue } from "@fundwave/fetchq";

const fetchQueue = new FetchQueue(); // concurent defaults to 3
const customFetch = fetchQueue.getFetchMethod();

const urls = [...]
const options = {...}

const promises = urls.map(async (url) => await customFetch(url, options))
const responses = await Promise.all(promises);
```

```js
// get queue length at real time
console.log(fetchQueue.getQueueLength());
```

```js
// getters and setters
fetchQueue.setConcurrent(5);
console.log(fetchedQueue.getConcurrent()); // output: 5

fetchQueue.setDebug(true);
console.log(fetchedQueue.getDebug()); // output: true
```

```js
// start and pause queue
const fetchQueue = new FetchQueue(concurrent: 3, pauseQueueOnInit: true);
const customFetch = fetchQueue.getFetchMethod();

// ...some calls
fetchQueue.emptyQueue();
fetchQueue.startQueue();

// ...some calls
fetchQueue.pauseQueue();
```

Note: See DOCUMENTATION.md for more information on methods.
npm package: @fundwave/oidc-client
Description: Client for managing tokens for API Calls
Author: The Fundwave Authors
Latest version: 3.0.0

## OIDC Client

@fundwave/oidc-client is a lightweight client-side library that allows you to prepare headers for your network-calls by automatically refreshing tokens (if expired) with the provided OIDC server.

### Installation

```sh
npm install @fundwave/oidc-client
```

### Initialization

```js
import { OIDCClient } from "@fundwave/oidc-client";

const oidcClient = new OIDCClient();

// Set the URL-String where token refresh requests will be sent
oidcClient.setBaseUrl("https://my-awesome-oidc-server.com");

// Set the path on the server which is responsible for the refresh
oidcClient.setRefreshPath("refresh-token");

```

  > Note: the `refreshPath` property defaults to **token/refresh**

### Usage

Once the class has been instantiated, you can

- use the `prepareHeaders` method to get the required headers for your calls

  ```js
  const headers = await oidcClient.prepareHeaders();
  ```

- Optionally, directly use the `getAccessToken` method to update the tokens (access and refresh) at browser's storage

  ```js
  await oidcClient.getAccessToken();
  ```

- If the refresh-token call returns a `401`/`403` or any other error status, the library will throw an custom-event `logged-out`

### Notes:

- Tokens aren't refreshed every time the `prepareHeaders` method is called. Tokens are only refreshed when the token is about to expire.

- If your client app makes parallel calls to the same object of oidc-client, this library will still make only one active call to your OIDC server. This will reduce network calls and avoid exceeding any rate limits with your OIDC server.

- **Access Token** is maintained at browser's _session storage_ with the key being `token`

- **Refresh Token** is maintained at browser's _local storage_ with the key being `refreshToken`

- The library will read tokens sent by your OIDC server from either the response **body** or **headers**
npm package: @funeralguide/react-form-validation-hoc
Description: React Higher Order Component to handle simple form validation
Author: Joao Moreira
Latest version: 1.0.10

# React Form Validation HOC #

## Installation

```npm install @funeralguide/react-form-validation-hoc```

## Usage

For the moment the component only works with the `yup` validation framework.

Import the component using
```javascript
import { withValidation } from '@funeralguide/react-form-validation-hoc';
```

And when exporting your React component, make sure to wrap it with `withValidation` such as
```javascript
export default withValidation(MyComponent);
```

By doing this your component will have four props injected to it


* `errors`

This is an Object with the error strings generated after calling `validate` against a specific validation schema. For example if you schema looks like this:

```javascript
export const validationSchema = object().shape({
  name: string().nullable().required('Name is required'),
  address: string().nullable().required('Address is required');
```

it will generate an `errors` object that looks like this

```javascript
errors: {
  name: 'Name is required',
  address: 'Address is required',
};
```


* `formRefs` (optional use)

This is a collection of React refs, used for scrolling to HTML elements that have errors. To use this effectively, you will need to set these refs in their respective Nodes in your JSX.

The structure of this object is similar to the `errors` object above. So given the same validation schema as above you would get the following:

```javascript
formRefs: {
  name: { current: {...} },
  address: { current: {...} },
};
```


* `validate(formData, validationSchema, scrollToElement)`

This is the method you will want to call when you want to validate your form data and generate any errors. This method takes two required arguments `formData` and `validationSchema` and an optional third argument if you want scrolling to errors functionality.


* `generateRefs(fields)` (optional use)

This method is used to generate the `formRefs` properties to mirror your validation schema. Typically you will want to pass an array of property names for your form data. For example using a Yup validation schema:

```javascript
generateRefs(Object.keys(validationSchema.fields));
```

Make sure to call this method in your component's `constructor` or in `componentDidMount` if you want to use scroll to error functionality.