open-index/open-npm huggingface dataset:
npm package: @mgwalker/chartjs-node
Description: Wrapper for creating Chart.js charts from Node
Author: Greg Walker
Latest version: 0.0.2

[![snapshot test status badge](https://github.com/mgwalker/chartjs-node/actions/workflows/test.yaml/badge.svg)](https://github.com/mgwalker/chartjs-node/actions/workflows/test.yaml)

# Chart.js-node

Build static [Chart.js](https://www.chartjs.org) 3.x charts in Node. It's a lot
like using Chart.js directly, but with a few tweaks.

### Getting started

```shell
npm install @mgwalker/chartjs-node
```

And then to use it:

```javascript
import Chart from "chartjs-node";

const myChart = new Chart([width, height], config);
```

The `config` option is a complete [Chart.js configuration](https://www.chartjs.org/docs/latest/configuration/)
object, including datasets, options, etc. Note that `options.animations` is
always set to `false` since the rendered image is static.

chartjs-node includes [chartjs-adapter-luxon](https://github.com/chartjs/chartjs-adapter-luxon),
[chartjs-plugin-annotation](https://github.com/chartjs/chartjs-plugin-annotation), and
[chartjs-plugin-datalabels](https://github.com/chartjs/chartjs-plugin-datalabels),
so you can also use any configuration for those. Please note that the datalabels
plugin is disabled unless you provide configuration for it.

> Other plugins are not included because they don't work with Chart.js 3.x.

The `config` can also include some options that are specific to chartjs-node:

| path                      | description                                                                                        | default |
| ------------------------- | -------------------------------------------------------------------------------------------------- | ------- |
| `deviceScaleFactor`       | When rendering the image, what device scale factor to use. Set larger to get clearer antialiasing. | 1       |
| `options.backgroundColor` | The background color of the generated chart.                                                       | `white` |

To save your chart:

```javascript
await myChart.save([path]);
```

If `path` is provided, the chart will be saved as a PNG to the provided path. If
`path` is omitted, `save()` will resolve with a buffer containing the PNG.
npm package: @mgwalker/promise-throttle
Description: Perform an asynchronous callback on an array of items, limited to a certain number of simultaneous instances, until the entire list has been iterated.
Latest version: 1.0.2

# promise-throttle

This is a simple library for running an asynchronous callback on a list of
items, but throttling down to a maximum number of _simultaneous_ executions.
For example, imagine you wanted to check the validity of a hundred links on a
website. You might not want to fire off 100 requests all at once because that
would be hard on your system and rude to the server. Instead, maybe you want to
make 3 requests at a time, one after the other, until they have all finished.
This library helps you do that.

`promise-throttle` makes two guarantees: the callback will be passed values from
the list in list order, and the final resolved list will be the results of the
callback also in list order.

## Usage

```js
import throttle from "@mgwalker/promise-throttle";

const timesToWait = [10, 30, 4, 97, 16, 40, 12, 70, 2];

const callback = (timeToWait) =>
  new Promise((resolve) => {
    setTimeout(() => {
      resolve(`I have waited for ${timeToWait} seconds`);
    }, timeToWait * 1_000);
  });

const results = await throttle(timesToWait, callback, 3);
```

In this example, when `throttle` is called, the values `10`, `30`, and `4` are
immediately sent to the callback function, which waits for the specified number
of seconds before resolving with a message that it has waited. After 4 seconds,
the third callback resolves, so it is called a fourth time with the value `97`.
Six seconds later, the first callback resolves, resulting in a fifth call with
the value `16`, and so on.

And the end of execution, the value of `results` will be:

```js
[
  "I have waited for 10 seconds",
  "I have waited for 30 seconds",
  "I have waited for 4 seconds",
  "I have waited for 97 seconds",
  "I have waited for 16 seconds",
  "I have waited for 40 seconds",
  "I have waited for 12 seconds",
  "I have waited for 70 seconds",
  "I have waited for 2 seconds",
];
```