open-index/open-npm huggingface dataset:
npm package: @superbrave/eslint-config
Description: Eslint config for SuperBrave frontend projects
Author: Superbrave
Latest version: 0.1.6

# @superbrave/eslint-config

Eslint config for Superbrave frontend projects

### Want to make changes?

1. Run `npm install`
2. Update `index.js` with desired settings
3. If you haven't done so, copy .env file: `$ cp .env.dist .env`
4. Create a personal access token in Github and paste token in `GITHUB_TOKEN` variable in `.env` file
5. Release your version: `$ npm run release` and follow prompt
npm package: @superbrave/prettier-config
Description: Prettier config for SuperBrave frontend projects
Author: Superbrave
Latest version: 0.0.2

# @superbrave/prettier-config

Prettier config for Superbrave frontend projects

### Want to make changes?

1. Run `npm install`
2. Update `prettier.config.js` with desired settings
3. If you haven't done so, copy .env file: `$ cp .env.dist .env`
4. Create a personal access token in Github and paste token in `GITHUB_TOKEN` variable in `.env` file
5. Release your version: `$ npm run release` and follow prompt
npm package: @superbuilders/duckdb-bindings
Description: DuckDB Node.js bindings with serverless HOME fix
Latest version: 1.4.3-serverless.4

# DuckDB Node Bindings

[Node](https://nodejs.org/) bindings to the [DuckDB C API](https://duckdb.org/docs/api/c/overview).

See [@duckdb/node-api](https://www.npmjs.com/package/@duckdb/node-api) for a high-level API built on these low-level bindings.

### Supported Platforms

- Linux arm64
- Linux x64
- Mac OS X (Darwin) arm64 (Apple Silicon)
- Mac OS X (Darwin) x64 (Intel)
- Windows (Win32) x64
npm package: @superbuilders/duckdb-bindings-linux-x64
Description: DuckDB Node.js bindings for Linux x64 with serverless HOME fix
Latest version: 1.4.3-serverless.4

# DuckDB Node Bindings: Linux x64

Binaries supporting [Node](https://nodejs.org/) bindings to the [DuckDB C API](https://duckdb.org/docs/api/c/overview) for Linux x64.

See [@duckdb/node-bindings](https://www.npmjs.com/package/@duckdb/node-bindings) for a low-level API that uses these binaries, or [@duckdb/node-api](https://www.npmjs.com/package/@duckdb/node-api) for a high-level API built on those bindings.
npm package: @superbuilders/kas
Description: A lightweight JavaScript CAS for comparing expressions and equations.
Author: Khan Academy
Latest version: 2.0.10

# @khanacademy/kas

A lightweight JavaScript CAS (Computer Algebra System) for comparing expressions and equations.
It is used throughout [Khan Academy](https://khanacademy.org)'s interactive exercises.

## What can it do?

It can parse plain text math, LaTeX, or a mix of both:

```js
var expr = KAS.parse("3x \\frac{42}{42} sin^2y").expr;
expr.print();
// "3*x*42/42*sin(y)^(2)"
```

It can evaluate expressions:

```js
var expr = KAS.parse("(x^2+y^2)^.5").expr;
expr.eval({x: 3, y: 4});
// 5
```

It can compare expressions and equations:

```js
var expr1 = KAS.parse("(1-x)(-1-6x)").expr;
var expr2 = KAS.parse("(6x+1)(x-1)").expr;
KAS.compare(expr1, expr2).equal;
// true

var eq1 = KAS.parse("2w+50/w=25").expr;
var eq2 = KAS.parse("w(12.5-w)=25").expr;
KAS.compare(eq1, eq2).equal;
// true
```

It can perform basic transforms that always simplify an expression:

```js
var expr = KAS.parse("1+1+x+x+x+y").expr;
expr.collect().print();
// "2+3*x+y"

var expr = KAS.parse("b^(2*y*log_b x)").expr;
expr.collect().print();
// "x^(2*y)"
```

It can perform non-simplifying transforms on an expression:

```js
var expr = KAS.parse("ab(c+d)e^f").expr;
expr.print();
// "a*b*(c+d)*e^(f)"
expr.expand().print();
// "a*b*e^(f)*c+a*b*e^(f)*d"
expr.expand().factor().print();
// "a*b*e^(f)*(c+d)"
```

It can combine the above abilities to perform powerful simplification:

```js
var expr = KAS.parse("((nx^5)^5)/(n^-2x^2)^-3").expr;
expr.print();
// "(n*x^(5))^(5)*(n^(-2)*x^(2))^(-1*-3)"
expr.simplify().print();
// "n^(-1)*x^(31)"

var expr = KAS.parse("(15np-25mp)/(15p^2-5p)+(20mp+10p^2)/(15p^2-5p)").expr;
expr.print();
// "(15*n*p+-25*m*p)*(15*p^(2)+-5*p)^(-1)+(20*m*p+10*p^(2))*(15*p^(2)+-5*p)^(-1)"
expr.simplify().print();
// "(-1+3*p)^(-1)*(3*n+-1*m+2*p)"
```

## How to build the library
    pnpm install
    pnpm build

## How to build the parser
First, make any changes in `src/parser-generator.js`

    pnpm install
    pnpm build:parser

## License
[MIT License](http://opensource.org/licenses/MIT)
npm package: @superbuilders/keypad-context
Description: Perseus keypad context
Author: Khan Academy
Latest version: 3.0.24

# @khanacademy/keypad

This is meant to be a temporary fix for a problem with @khanacademy/math-input.

It provides a context that allows the mobile MathInput keypad to communicate with the MathInput Mathquill input wrapper.

For internal KA people, see: LEMS-2246
npm package: @superbuilders/math-input
Description: Khan Academy's new expression editor for the mobile web.
Author: Khan Academy
Latest version: 26.0.13

# @khanacademy/math-input

Khan Academy's expression editor for the web. Used in the [Perseus](https://github.com/khan/perseus) exercise framework to power math input and expression editing on all screens.

Built with [React](https://github.com/facebook/react), [MathQuill](https://github.com/mathquill/mathquill), [Aphrodite](https://github.com/khan/aphrodite), and more.

![](https://cloud.githubusercontent.com/assets/1309177/15994911/d1acd29e-30c5-11e6-9707-6bef8e69114f.gif)

Try it yourself on [Khan Academy](https://www.khanacademy.org/math/algebra-basics/alg-basics-algebraic-expressions/alg-basics-distributive-property/e/distributive-property-with-variables). (Note: you'll need to enable mobile emulation, if you're accessing the site from a desktop browser.)

## Getting started

- Clone the project: `git clone git@github.com:Khan/math-input.git`
- Install dependencies: `pnpm install`
- Start the development server: `pnpm start`

When you start the project you'll need to be on a device that supports touch or touch emulation to see the keyboard. The easiest way to get started is open the developer tools on Google Chrome.

## Supported Features

- Multiple keypad configurations, so as to accommodate a range of input types (i.e., fractions/mixed numbers, algebraic expressions).
- Multi-page keypads, with swipeable page navigation.
- Touch-and-drag interactions (as supported by the stock iOS and Android keypads).
- A draggable cursor with a detached handle, for fine-grained control on touch devices.
- Custom state transitions for the editing experience, to streamline expression entry.

![](https://cloud.githubusercontent.com/assets/1309177/15994912/d2b60cdc-30c5-11e6-8eb4-9086d76f327c.gif)

## License

[MIT License](http://opensource.org/licenses/MIT)
npm package: @superbuilders/perseus
Description: Core Perseus API (includes renderers and widgets)
Author: Khan Academy
Latest version: 65.4.7

# @khanacademy/perseus

Perseus is the set of components that we use at Khan Academy to power our Exercises and Articles.

The [perseus monorepo](https://www.github.com/Khan/perseus) is home to several packages, and this is the main one! Import this to render perseus items. Currently, UI that's outside of a perseus item (check answer button, anything at the higher-than-assessment-item level) is left as an exercise for the client.
npm package: @superbuilders/perseus-editor
Description: Perseus editors
Author: Khan Academy
Latest version: 25.1.3

# @khanacademy/perseus-editor

The Perseus editor package contains components for editing Perseus content, but not for rendering Perseus content on its own. It is nevertheless very tightly coupled to perseus core.

Each core perseus widget type has a corresponding editor (defined in perseus-editor/widgets/), and there are also some extra example/test widgets defined in `./testing-widgets.js`.
npm package: @superbuilders/perseus-linter
Description: Linter engine for Perseus
Author: Khan Academy
Latest version: 4.0.11

# @khanacademy/perseus-linter

> It’s to Perseus JSON what ESLint is to Javascript.
>
> \- Jeremy, on the role of perseus-linter

A set of linting rules to help content creators use Perseus. Finds common pitfalls and lets editors know.
npm package: @superbuilders/pure-markdown
Description: SimpleMarkdown instance with non-react Perseus rules
Author: Khan Academy
Latest version: 2.0.10

# @khanacademy/pure-markdown

An extended version of `@khanacademy/simple-markdown`, `pure-markdown` is a Node-compatible wrapper around `simple-markdown`.

Contains markdown related functions in pure javascript, extracted from perseus-markdown.jsx.

Note that this file may be used in stand alone nodejs, thus do not import anything from Perseus.
npm package: @supercake-libs/eslint-config-supercake
Description: Eslint config for SuperCake
Author: DevBrooklyn
Latest version: 1.0.0

# eslint-config-supercake

SuperCake Eslint config with:

- Airbnb config
- Typescript
- Prettier

## Usage

```
npx install-peerdeps --dev @supercake-libs/eslint-config-supercake
```

Add `"extends": "@supercake-libs/eslint-config-supercake"` to your eslint config file.
npm package: @supercake-libs/uikit
Description: Set of UI components for supercake projects
Latest version: 1.0.0

# 🥞 SuperCake UIkit

[![Version](https://img.shields.io/npm/v/@supercake-libs/uikit)](https://www.npmjs.com/package/@supercake-libs/uikit) [![Size](https://img.shields.io/bundlephobia/min/@supercake-libs/uikit)](https://www.npmjs.com/package/@supercake-libs/uikit)

Pancake UIkit is a set of React components and hooks used to build pages on Supercake's apps. It also contains a theme file for dark and light mode.

## Install

`yarn add @supercake-libs/uikit`

## Setup

### Theme

Before using SuperCake UIkit, you need to provide the theme file to styled-component.

```
import { ThemeProvider } from 'styled-components'
import { light, dark } from '@supercake-libs/uikit'
...
<ThemeProvider theme={isDark}>...</ThemeProvider>
```

### Reset

A reset CSS is available as a global styled component.

```
import { ResetCSS } from '@supercake-libs/uikit'
...
<ResetCSS />
```

### Types

This project is built with Typescript and export all the relevant types.

## How to use the UIkit

If you want to use components from the UIkit, check the [Storybook documentation](https://supercake.github.io/supercake-uikit/)
npm package: @supercat1337/dictionary
Description: A simple data structure that maps keys to arrays of values, enabling efficient storage and retrieval of multiple values per key.
Author: Supercat
Latest version: 1.0.0

# Dictionary

A simple data structure that maps keys to arrays of values, enabling efficient storage and retrieval of multiple values per key.

## Installation

You can install the package via npm:
`npm install @supercat1337/dictionary`

## Usage

Here is an example usage of the Dictionary class:
```js
import { Dictionary } from '@supercat1337/dictionary';

const dictionary = new Dictionary();
dictionary.add('key', 'value');
dictionary.add('key', 'value2');
// same as dictionary.add('key', 'value', 'value2');

dictionary.add('key2', 'value3');

console.log(dictionary.getLastValue('key')); // 'value2'
console.log(dictionary.get('key')); // ['value', 'value2']
console.log(dictionary.keys()); // ['key', 'key2']
console.log(dictionary.size); // 2

dictionary.clear('key');
console.log(dictionary.get('key')); // []

dictionary.remove('key');
console.log(dictionary.get('key')); // undefined

dictionary.removeAll();
console.log(dictionary.size); // 0

dictionary.add('key', 'value', 'value2');
dictionary.add('key2', 'value3');

dictionary.iterateAll((key, value) => {
    console.log(key, value);
});
// "key", "value"
// "key", "value2"
// "key2", "value3"

```
## Properties

### size

The number of keys in the dictionary.

## Methods

### add(key, value)

Adds a value to a key in the dictionary. If the key is not in the dictionary, it will be added.

### get(key)

Returns the values associated with a key in the dictionary. If the key is not in the dictionary, it will return an empty array.

### getLastValue(key)

Returns the last value associated with a key in the dictionary. If the key is not in the dictionary, it will return undefined.

### exists(key)

Checks if a key exists in the dictionary.

### clear(key)

Clears the values associated with the given key in the dictionary, setting it to an empty array.

### remove(key)

Removes a key and its associated values from the dictionary.

### removeAll(key)

Removes all keys and their associated values from the dictionary.

### keys()

Returns an array of keys in the dictionary.

### iterateAll(callback)

Calls the given callback function for each value in the dictionary.

### iterate(callback)

Calls the given callback function for each value associated with a key in the dictionary.

## License

MIT
npm package: @supercat1337/domain-extractor
Description: This tool extracts domains from an X.509 certificate, helping you identify domains linked to a given IP address or URL.
Author: Supercat1337
Latest version: 1.0.0

# Domain Extractor

This tool extracts domains from an X.509 certificate, helping you identify domains linked to a given IP address or URL.

## Usage

```js
// @ts-check

import { extractDomainsFromCertificate } from "@supercat1337/domain-extractor";

let result = await extractDomainsFromCertificate("8.8.8.8");
console.log(JSON.stringify(result));
// Outputs: {"url":"8.8.8.8","domains":["dns.google","dns.google.com","8888.google","dns64.dns.google"],"error":null}

let result2 = await extractDomainsFromCertificate("https://google.com");
console.log(JSON.stringify(result2));
// Outputs:
// {
//     url: "https://google.com",
//     domains: [
//         "google.com",
//         "appengine.google.com",
//         "bdn.dev",
//         "origin-test.bdn.dev",
//         "cloud.google.com",
//         "crowdsource.google.com",
//         "datacompute.google.com",
//         "google.ca",
//         "google.cl",
//         "google.co.in",
//         "google.co.jp",
//         "google.co.uk",
//         "google.com.ar",
//         "google.com.au",
//         "google.com.br",
//         "google.com.co",
//         "google.com.mx",
//         "google.com.tr",
//         "google.com.vn",
//         "google.de",
//         ...
//     ],
//     error: null
// }
```
npm package: @supercat1337/ls-cache
Description: Cache system based on localStorage
Author: SuperCat1337
Latest version: 1.0.3

# CacheStorage

A simple library to store and retrieve data in `localStorage` using a hashed URL as the key.

## Features

- Store and retrieve data in `localStorage` using a hashed URL as the key.
- Set a time-to-live (TTL) for cached data.
- Wait for the TTL to expire before removing the cached data.
- You can use your own hash function.
- You can remove all old keys from the cache based on a given date.

## Installation

You can install the library using npm:
```bash
npm install @supercat1337/ls-cache
```

## Usage

```js
import { CacheStorage } from '@supercat1337/ls-cache';

const cache = new CacheStorage();
const url = "https://example.com";

// Write a value to the cache
cache.write(
  url, // URL
  "Hello, world!", // Value
  1 // TTL in seconds
);

// Read a value from the cache
console.log(cache.read(url));
// Output: "Hello, world!"

// Wait for the cache to expire
setTimeout(() => {
  console.log(cache.read(url));
  // Output: null
}, 2000);

```

## CacheStorage Methods
Here are the methods available in the `CacheStorage` class:

- `write(url, value, ttl)`: Writes a value to the cache.
- `read(url)`: Reads a value from the cache. Returns `null` if the value is not found.
- `setKey(key, value, ttl)`: Writes a value to the cache. Key is the hashed URL. key is the hashed URL. value is the value to write. ttl is the time-to-live in seconds.
- `readKey(key)`: Reads a value from the cache. Key is the hashed URL. Returns object with start, end, and value if all exist, otherwise null.
- `getKeyName(text)`: Returns a base-36 hash of a given string by default. 
- `getKeyNames()`: Returns an array of all keys in the cache.
- `removeKey(key)`: Removes all records associated with a given key from the cache.
- `removeKeysCreatedBefore(created_date)`: Removes all records from the cache that were created before a specified date.
- `removeOutdatedKeys()`: Removes all outdated keys from the cache. 
- `removeAll()`: Removes all records in the cache.

## cacheStorageConfig Object

cacheStorageConfig is a global object that can be used to configure the library.
You can use your own hash function or Storage object.

```js
import { CacheStorage, cacheStorageConfig } from '@supercat1337/ls-cache';
import { Window } from "happy-dom";

const window = new Window({ url: "https://localhost:8080" });

cacheStorageConfig.storage = window.localStorage;
cacheStorageConfig.keyEncoder = (text) => {
    // Your own hash function
    return text;
}
```
npm package: @supercat1337/luhn
Description: A simple Luhn algorithm implementation in JavaScript
Author: Supercat
Latest version: 1.0.0

# **@supercat1337/luhn**

A simple Luhn algorithm implementation in JavaScript.

## Installation

```bash
npm i @supercat1337/luhn
```

## Usage

```js
import { luhnCalculate, luhnValidate } from "@supercat1337/luhn";

// All valid credit card numbers
const valid1 = "4539677908016808";
const valid2 = "5535766768751439";
const valid3 = "371612019985236";
const valid4 = "6011144340682905";
const valid5 = "4539404967869666";

// All invalid credit card numbers
const invalid1 = "4532778771091795";
const invalid2 = "5795593392134643";
const invalid3 = "375796084459914";
const invalid4 = "6011127961777935";
const invalid5 = "5382019772883854";

for (const valid of [valid1, valid2, valid3, valid4, valid5]) {
    console.log(`Validating ${valid}: ${luhnValidate(valid)}`);
}

for (const invalid of [invalid1, invalid2, invalid3, invalid4, invalid5]) {
    console.log(`Validating ${invalid}: ${luhnValidate(invalid)}`);
    console.log(
        `Calculating check digit for ${invalid.slice(0, -1)}: ${luhnCalculate(
            invalid.slice(0, -1)
        )}`
    );
}
```

## License

MIT License
npm package: @supercat1337/mysql-schema-parser
Description: A library for parsing and working with MySQL database schema metadata.
Author: Supercat1337
Latest version: 1.0.2

# @supercat1337/mysql-schema-parser

A library for parsing and working with MySQL database schema metadata.

## Installation

```bash
npm install @supercat1337/mysql-schema-parser
```

## Usage

```javascript
import fs from "node:fs";
import * as url from "url";
import { parseMySQLSchema } from "@supercat1337/mysql-schema-parser";

const __dirname = url.fileURLToPath(new URL(".", import.meta.url));

// Parse schema from JSON file
const db = parseMySQLSchema(
    JSON.parse(fs.readFileSync(__dirname + "data.json", "utf-8"))
);

console.log(db);
```

## API Reference

### Main Functions

#### `parseMySQLSchema(schema: ColumnMetadataRaw[]): MySQLDatabase`

Parses MySQL schema metadata into a structured `MySQLDatabase` object.

### Classes

#### `MySQLDatabase`

Represents a MySQL database with its tables.

-   **Properties**:

    -   `databaseName: string` - Name of the database
    -   `tables: Map<string, MySQLTable>` - Map of tables in the database

-   **Methods**:
    -   `addTable(table: MySQLTable): void` - Adds a table to the database

#### `MySQLTable`

Represents a MySQL table with its columns.

-   **Properties**:

    -   `tableName: string` - Name of the table
    -   `columns: Map<string, MySQLTableColumn>` - Map of columns in the table

-   **Methods**:
    -   `addColumn(column: MySQLTableColumn): void` - Adds a column to the table
    -   `getColumns(): MySQLTableColumn[]` - Returns all columns in the table
    -   `getColumn(columnName: string): MySQLTableColumn | null` - Gets a column by name
    -   `generateCreateTableQuery(options): string` - Generates CREATE TABLE SQL statement

#### `MySQLTableColumn`

Represents a column in a MySQL table.

-   **Properties**: All properties from `ColumnMetadataParams` type
-   **Methods**:
    -   `importFromRawData(rawMetadata: ColumnMetadataRaw): void` - Imports raw metadata
    -   `isPrimaryKey(): boolean` - Checks if column is a primary key
    -   `allowsNull(): boolean` - Checks if column allows NULL values
    -   `isAutoIncrement(): boolean` - Checks if column auto-increments
    -   `getColumnDefinition(): string` - Gets full column definition
    -   `toJSON(): ColumnMetadataParams` - Returns JSON representation

### Types

#### `ColumnMetadataRaw`

Raw MySQL column metadata in snake_case format (direct from INFORMATION_SCHEMA).

#### `ColumnMetadataParams`

Normalized column metadata in camelCase format.

## Features

-   Parse raw MySQL schema metadata into structured objects
-   Generate CREATE TABLE statements from metadata
-   Type-safe access to database schema information
-   Comprehensive column metadata representation
-   Helper methods for common column checks (PK, nullable, etc.)

## License

MIT
npm package: @supercat1337/mysql-to-json
Description: A simple tool to convert MySQL tables to JSON
Author: supercat1337
Latest version: 1.0.7

# mysql-to-json

A useful tool to get information about MySQL databases in JSON format.

## Overview

`mysql-to-json` is a GUI tool that connects to a MySQL database and retrieves information about the database in JSON format. This tool helps you to easily explore and query the database.

## Installation

To install `mysql-to-json`, run the following command:

```
npm install -g @supercat1337/mysql-to-json
```

## Usage

To use `mysql-to-json`, run the following command:

```
mysql-to-json [--port PORT] [--db_port PORT] [--db_host HOST] [--user USER] [--password PASS] [--help]
```

You can customize the tool's behavior by passing options as command-line arguments. The available options are:

### Options

-   `--port PORT`: The port number to listen on. Default is 3000.
-   `--db_port PORT`: The port number of the MySQL database. Default is 3306.
-   `--db_host HOST`: The host of the MySQL database. Default is localhost.
-   `--user USER`: The user of the MySQL database. Default is root.
-   `--password PASS`: The password of the MySQL database. Default is empty.
-   `--help`: Show this help message.

## Example Usage

To retrieve information about a MySQL database on the default host and port:

```
mysql-to-json
```

To connect to a MySQL database on a remote host:

```
mysql-to-json --db_host example.com --db_port 3307 --user myuser --password mypass
```

## Output

The tool starts a local server on the specified port. Using a web browser, you can access the server and retrieve information about the database as JSON data.

## Contributing

Contributions are welcome! If you'd like to contribute to `mysql-to-json`, please fork this repository and submit a pull request.

## License

`mysql-to-json` is licensed under the MIT License.
npm package: @supercat1337/port
Description: A simple JavaScript library for finding available ports on your system.
Author: SuperCat1337
Latest version: 1.0.1

# supercat1337/port

## Overview

A simple JavaScript library for finding available ports on your system.

## Features

-   **Async API**: Use async/await to find available ports asynchronously
-   **Flexible port range**: Specify a starting port number to search from
-   **Support for IPv4 and IPv6**: Check availability of ports on both IPv4 and IPv6 addresses

## Installation

To install the library, run the following command:

```bash
npm install @supercat1337/port
```

## Usage

### getFreePort

Finds the first available port starting from the specified port number.

```javascript
import { getFreePort } from "@supercat1337/port";

async function findPort() {
    const port = await getFreePort(8080);
    console.log(`Available port: ${port}`);
}

findPort();
```

### isPortTaken

Checks if a given port is available for use or not.

```javascript
import { isPortTaken } from "@supercat1337/port";

async function checkPort() {
    const isTaken = await isPortTaken(8080);
    console.log(`Port 8080 is ${isTaken ? "taken" : "available"}`);
}

checkPort();
```

## API Documentation

### getFreePort(startingPort?)

-   `startingPort`: The port number to begin checking from (default: 8080)
-   Returns a promise that resolves to the first available port number

### isPortTaken(port, type?)

-   `port`: The port number to check the availability of
-   `type`: The type of the port to check (IPv4 or IPv6, default: IPv4)
-   Returns a promise that resolves to a boolean indicating if the port is available or not

## License

MIT
npm package: @supercat1337/queue
Description: Queue is a class that manages the tasks in the queue. It emits events when tasks are added or removed.
Author: Supercat
Latest version: 1.0.4



**Queue**
================

A JavaScript class for managing tasks in a queue.

**Overview**
------------

Queue is a lightweight JavaScript class that provides a simple way to manage tasks in a queue. It emits events when tasks are added or removed, and provides methods for adding, removing, and waiting for tasks to complete.

**Features**
------------

*   **Task Queue**: Queue allows you to add tasks to a queue and manage their execution.
*   **Event Emission**: Queue emits events when tasks are added or removed from the queue.
*   **Task Management**: Queue provides methods for adding, removing, and waiting for tasks to complete.

**Usage**
------------
```javascript
import { Queue } from "@supercat1337/queue"; // import Queue class

/**
 * Simulate a task that takes 1 second to complete.
 * @param {string} data - the task data
 */
async function task(data) { // define task function
    console.log(data); // log the task data
    await new Promise(resolve => setTimeout(resolve, 1000)); // wait 1 second
}

async function init() { 

    const queue = new Queue(); // create Queue instance
    const tasks_limit = 3; // set the limit of tasks in the queue

    let counter = 0; // initialize counter

    while (counter < 10) { // loop until counter is 10
        counter++; // increment counter

        queue.addTaskAndRun(async () => { // add task to queue and run it
            return task("task " + counter); // run the task
        });

        console.log("queue.size is " + queue.size); // log the size of the queue
        await queue.waitForLessThan(tasks_limit); // wait until the number of tasks in the queue is less than tasks_limit
    }

    await queue.waitUntilEmpty(); // wait until all tasks are completed
}

await init(); // call init function
```

**API Documentation**
--------------------

### Queue Class

### Methods
*   `addTaskAndRun(task)`: Add a task to the queue and run it. If the task resolves, it is removed from the queue. If the task rejects, the error is logged to the console and the task is removed from the queue.
*   `waitForLessThan(limit)`: Wait until the number of tasks in the queue is less than the specified limit.
*   `waitUntilEmpty()`: Wait until all tasks are completed.
*   `add(...data)`: Add a task to the queue and return its task ID.
*   `remove(taskId)`: Remove a task from the queue by its task ID.
*   `on(event, listener)`: Subscribe to events on the Queue instance.

### Properties
*   `size`: The number of tasks in the queue.   

### Events
*   `add`: Emitted when a task is added to the queue.
*   `remove`: Emitted when a task is removed from the queue.

**License**
-------

Queue is licensed under the [MIT License](https://opensource.org/licenses/MIT).

**Contributing**
------------

Contributions are welcome! Please submit a pull request with your changes.
npm package: @supercharge/arrays
Description: Array utilities for Node.js and JavaScript
Author: Marcus Pöhls
Latest version: 4.5.0

<div align="center">
  <a href="https://superchargejs.com">
    <img width="471" style="max-width:100%;" src="https://superchargejs.com/images/supercharge-text.svg" />
  </a>
  <br/>
  <br/>
  <p>
    <h3>Arrays</h3>
  </p>
  <p>
    Array utilities for JavaScript and Node.js
  </p>
  <br/>
  <p>
    <a href="#installation"><strong>Installation</strong></a> ·
    <a href="#Docs"><strong>Docs</strong></a> ·
    <a href="#usage"><strong>Usage</strong></a>
  </p>
  <br/>
  <br/>
  <p>
    <a href="https://www.npmjs.com/package/@supercharge/arrays"><img src="https://img.shields.io/npm/v/@supercharge/arrays.svg" alt="Latest Version"></a>
    <a href="https://www.npmjs.com/package/@supercharge/arrays"><img src="https://img.shields.io/npm/dm/@supercharge/arrays.svg" alt="Monthly downloads"></a>
  </p>
  <p>
    <em>Follow <a href="http://twitter.com/marcuspoehls">@marcuspoehls</a> and <a href="http://twitter.com/superchargejs">@superchargejs</a> for updates!</em>
  </p>
</div>

---

## Introduction
The `@supercharge/arrays` package provides chainable array utilities for Node.js and JavaScript. It’s a wrapper around JavaScript arrays providing useful methods like `.isEmpty()`, `.length()`, `.flatMap()`, `.contains()`, and many more.


## Installation

```
npm i @supercharge/arrays
```


## Docs
Find all the [details for `@supercharge/arrays` in the extensive Supercharge docs](https://superchargejs.com/docs/arrays).


## Usage
Using `@supercharge/arrays` is pretty straightforward. The package exports a function wrapping an array or individual items as an argument. You can then fluently chain methods interacting with your data:

```js
const { Arr } = require('@supercharge/arrays')

const users = Arr.from([])

users.isEmpty()
// true

users
  .push({ id: 1, name: 'Marcus' })
  .push({ id: 2, name: 'Norman' })
  .push({ id: 3, name: 'Christian' })

users.isNotEmpty()
// true

users.length()
// 3

const usernamesArray = users
  .map(user => user.name)
  .toArray()
// [ 'Marcus', 'Norman', 'Christian' ]

const marcus = users.find(user => {
  return user.name === 'Marcus'
})
// { id: 1, name: 'Marcus' }
```

Every method in the chain returns a `@supercharge/array` instance. This way, you can chain further methods without leaving the fluent interface. Call `.all()` to retrieve the plain JavaScript array.


## Contributing
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊

1.  Create a fork
2.  Create your feature branch: `git checkout -b my-feature`
3.  Commit your changes: `git commit -am 'Add some feature'`
4.  Push to the branch: `git push origin my-new-feature`
5.  Submit a pull request 🚀


## License
MIT © [Supercharge](https://superchargejs.com)

---

> [superchargejs.com](https://superchargejs.com) &nbsp;&middot;&nbsp;
> GitHub [@supercharge](https://github.com/supercharge) &nbsp;&middot;&nbsp;
> Twitter [@superchargejs](https://twitter.com/superchargejs)
npm package: @supercharge/cedar
Description: Build beautiful command line applications
Author: Marcus Pöhls
Latest version: 2.0.0

<div align="center">
  <a href="https://superchargejs.com">
    <img width="471" style="max-width:100%;" src="https://superchargejs.com/images/supercharge-text.svg" />
  </a>
  <br/>
  <br/>
  <p>
    <h3>Cedar</h3>
  </p>
  <p>
    Build beautiful console applications.
  </p>
  <br/>
  <p>
    <a href="#installation"><strong>Installation</strong></a> ·
    <a href="#docs"><strong>Docs</strong></a> ·
    <a href="#api"><strong>API</strong></a>
  </p>
  <br/>
  <br/>
  <p>
    <a href="https://www.npmjs.com/package/@supercharge/cedar"><img src="https://img.shields.io/npm/v/@supercharge/cedar.svg" alt="Latest Version"></a>
    <a href="https://www.npmjs.com/package/@supercharge/cedar"><img src="https://img.shields.io/npm/dm/@supercharge/cedar.svg" alt="Monthly downloads"></a>
  </p>
  <p>
    <em>Follow <a href="http://twitter.com/marcuspoehls">@marcuspoehls</a> and <a href="http://twitter.com/superchargejs">@superchargejs</a> for updates!</em>
  </p>
</div>

---

## Introduction
The `@supercharge/cedar` package allows you to create beautiful console applications.


## Installation

```
npm i @supercharge/cedar
```


## Docs
Find all the [details for `@supercharge/cedar` in the extensive Supercharge docs](https://superchargejs.com/docs/console).


## Usage
Using `@supercharge/cedar` is pretty straightforward. The package exports a handful of methods that you can reach for when requiring the package:

```js
const { Application } = require('@supercharge/cedar')

async function run () {
  const app = new Application('console-app-name')
  await app.run()
}
```


## Contributing
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊

1.  Create a fork
2.  Create your feature branch: `git checkout -b my-feature`
3.  Commit your changes: `git commit -am 'Add some feature'`
4.  Push to the branch: `git push origin my-new-feature`
5.  Submit a pull request 🚀


## License
MIT © [Supercharge](https://superchargejs.com)

---

> [superchargejs.com](https://superchargejs.com) &nbsp;&middot;&nbsp;
> GitHub [@supercharge](https://github.com/supercharge) &nbsp;&middot;&nbsp;
> Twitter [@superchargejs](https://twitter.com/superchargejs)
npm package: @supercharge/classes
Description: Class utilities for Node.js and JavaScript
Author: Marcus Pöhls
Latest version: 2.0.0

<div align="center">
  <a href="https://superchargejs.com">
    <img width="471" style="max-width:100%;" src="https://superchargejs.com/images/supercharge-text.svg" />
  </a>
  <br/>
  <br/>
  <p>
    <h3>Classes</h3>
  </p>
  <p>
    Class utilities for Node.js and JavaScript
  </p>
  <br/>
  <p>
    <a href="#installation"><strong>Installation</strong></a> ·
    <a href="#usage"><strong>Usage</strong></a> ·
    <a href="#api"><strong>API</strong></a>
  </p>
  <br/>
  <br/>
  <p>
    <a href="https://www.npmjs.com/package/@supercharge/classes"><img src="https://img.shields.io/npm/v/@supercharge/classes.svg" alt="Latest Version"></a>
    <a href="https://www.npmjs.com/package/@supercharge/classes"><img src="https://img.shields.io/npm/dm/@supercharge/classes.svg" alt="Monthly downloads"></a>
  </p>
  <p>
    <em>Follow <a href="http://twitter.com/marcuspoehls">@marcuspoehls</a> and <a href="http://twitter.com/superchargejs">@superchargejs</a> for updates!</em>
  </p>
</div>

---

## Introduction
The `@supercharge/classes` package provides a handful methods around classes in Node.js and JavaScript. For example, determine whether a given input is a class using the `.isClass(input)` method.


## Installation

```
npm i @supercharge/classes
```


## Usage
Using `@supercharge/classes` is pretty straightforward. Install and import the package and use it right away:

```js
const { isClass } = require('@supercharge/classes')

isClass(class Rabbit {})
// true

isClass(function classLikeRabbitFunc () {})
// false
```


## API

#### `isClass(input)`
Determine whether the given `input` is a class.

```js
const { isClass } = require('@supercharge/classes')

isClass(class YourClass {})
// true
```


#### `isFunction(input)`
Determine whether the given `input` is a function.

```js
const { isFunction } = require('@supercharge/classes')

isFunction(function sum () {})
// true
```


## Contributing
Do you miss a class-related function? We very much appreciate your contribution! Please send in a pull request 😊

1.  Create a fork
2.  Create your feature branch: `git checkout -b my-feature`
3.  Commit your changes: `git commit -am 'Add some feature'`
4.  Push to the branch: `git push origin my-new-feature`
5.  Submit a pull request 🚀


## License
MIT © [Supercharge](https://superchargejs.com)

---

> [superchargejs.com](https://superchargejs.com) &nbsp;&middot;&nbsp;
> GitHub [@supercharge](https://github.com/supercharge) &nbsp;&middot;&nbsp;
> Twitter [@superchargejs](https://twitter.com/superchargejs)
npm package: @supercharge/create-app
Description: Scaffold a new Supercharge application with one command
Author: Marcus Pöhls
Latest version: 1.1.0

<div align="center">
  <a href="https://superchargejs.com">
    <img width="471" style="max-width:100%;" src="https://superchargejs.com/images/supercharge-text.svg" />
  </a>
  <br/>
  <br/>
  <p>
    <h3>Create a Supercharge App</h3>
  </p>
  <p>
    Scaffold a new Supercharge application with one command
  </p>
  <br/>
  <br/>
  <p>
    <a href="https://www.npmjs.com/package/@supercharge/create-app"><img src="https://img.shields.io/npm/v/@supercharge/create-app.svg" alt="Latest Version"></a>
  </p>
  <p>
    <em>Follow <a href="http://twitter.com/marcuspoehls">@marcuspoehls</a> and <a href="http://twitter.com/superchargejs">@superchargejs</a> for updates!</em>
  </p>
</div>

---


## Create a Supercharge App
This is the entrypoint to scaffold a new Supercharge application. This repository follows the requirements of [npm init](https://docs.npmjs.com/cli/v7/commands/npm-init) to simply initialize a project using a single command:

```bash
npm init @supercharge/app your-app-name
```

This command creates a `your-app-name` directory in your current working directory and scaffolds a new Supercharge application inside of that folder:


## Contributing
We appreciate your contribution! Have an idea what we can add to this application? Please send in a pull request 😊

1.  Create a fork
2.  Create your feature branch: `git checkout -b my-feature`
3.  Commit your changes: `git commit -am 'Add some feature'`
4.  Push to the branch: `git push origin my-new-feature`
5.  Submit a pull request 🚀

---

> [superchargejs.com](https://superchargejs.com) &nbsp;&middot;&nbsp;
> GitHub [@supercharge](https://github.com/supercharge/) &nbsp;&middot;&nbsp;
> Twitter [@superchargejs](https://twitter.com/superchargejs)
npm package: @supercharge/doubly-linked-list
Description: A Doubly Linked List implementation for JavaScript
Author: Marcus Pöhls
Latest version: 1.0.0

<div align="center">
  <a href="https://superchargejs.com">
    <img width="471" style="max-width:100%;" src="https://superchargejs.com/images/supercharge-text.svg" />
  </a>
  <br/>
  <br/>
  <p>
    <h3>Doubly Linked List</h3>
  </p>
  <p>
    Doubly Linked List data structure for JavaScript
  </p>
  <br/>
  <p>
    <a href="#installation"><strong>Installation</strong></a> ·
    <a href="#resources"><strong>Docs</strong></a> ·
    <a href="#quick-usage-overview"><strong>Usage</strong></a>
  </p>
  <br/>
  <br/>
  <p>
    <a href="https://www.npmjs.com/package/@supercharge/doubly-linked-list"><img src="https://img.shields.io/npm/v/@supercharge/doubly-linked-list.svg" alt="Latest Version"></a>
    <a href="https://www.npmjs.com/package/@supercharge/doubly-linked-list"><img src="https://img.shields.io/npm/dm/@supercharge/doubly-linked-list.svg" alt="Monthly downloads"></a>
  </p>
  <p>
    <em>Follow <a href="http://twitter.com/marcuspoehls">@marcuspoehls</a> and <a href="http://twitter.com/superchargejs">@superchargejs</a> for updates!</em>
  </p>
</div>

---

## Introduction
The `@supercharge/doubly-linked-list` package provides a JavaScript implementation for the Doubly Linked List data structure.


## Installation

```
npm i @supercharge/doubly-linked-list
```


## Resources

- 📖 &nbsp;[Documentation](https://superchargejs.com/docs/doubly-linked-list)


## Quick Usage Overview
Using `@supercharge/doubly-linked-list` is pretty straightforward. The package exports a `LinkedList` class providing all methods to interact with the instance.

```js
const { DoublyLinkedList } = require('@supercharge/doubly-linked-list')

const list = new DoublyLinkedList()

list.isEmpty() // true
list.push(1, 2)
list.isNotEmpty() // true

list.head().value() // 1
list.tail().value() // 2
list.tail().prev().value() // 1
```


## Contributing
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊

1.  Create a fork
2.  Create your feature branch: `git checkout -b my-feature`
3.  Commit your changes: `git commit -am 'Add some feature'`
4.  Push to the branch: `git push origin my-new-feature`
5.  Submit a pull request 🚀


## License
MIT © [Supercharge](https://superchargejs.com)

---

> [superchargejs.com](https://superchargejs.com) &nbsp;&middot;&nbsp;
> GitHub [@supercharge](https://github.com/supercharge) &nbsp;&middot;&nbsp;
> Twitter [@superchargejs](https://twitter.com/superchargejs)
npm package: @supercharge/errors
Description: Useful JavaScript error classes
Author: Marcus Pöhls
Latest version: 2.0.1

<div align="center">
  <a href="https://superchargejs.com">
    <img width="471" style="max-width:100%;" src="https://superchargejs.com/images/supercharge-text.svg" />
  </a>
  <br/>
  <br/>
  <p>
    <h3>Errors</h3>
  </p>
  <p>
    JavaScript error classes with useful defaults
  </p>
  <br/>
  <p>
    <a href="#installation"><strong>Installation</strong></a> ·
    <a href="#quick-usage-overview"><strong>Usage</strong></a>
  </p>
  <br/>
  <br/>
  <p>
    <a href="https://www.npmjs.com/package/@supercharge/errors"><img src="https://img.shields.io/npm/v/@supercharge/errors.svg" alt="Latest Version"></a>
    <a href="https://www.npmjs.com/package/@supercharge/errors"><img src="https://img.shields.io/npm/dm/@supercharge/errors.svg" alt="Monthly downloads"></a>
  </p>
  <p>
    <em>Follow <a href="http://twitter.com/marcuspoehls">@marcuspoehls</a> and <a href="http://twitter.com/superchargejs">@superchargejs</a> for updates!</em>
  </p>
</div>

---

## Introduction
The `@supercharge/errors` package provides error classes with useful defaults. This avoids the boilerplate of setting up a custom error class in different projects.

- provides an `Error` base class capturing the stack trace by default
- every error has a `name` property providing the error’s class name
- exposes an `HttpError` class with HTTP `status` and error `code` properties


## Installation

```
npm i @supercharge/errors
```


## Quick Usage Overview
Using `@supercharge/errors` is pretty straightforward. The package exports error classes that you can use like the native `Error` class.

```js
const { Error, HttpError } = require('@supercharge/errors')

// works like the native `Error` class and also contains the stacktrace
throw new Error('your error message')

// the HTTP Error provides a fluent interface to customize the properties
throw new HttpError('Request validation failed')
  .withStatus(400)
  .withCode('E_YOUR_CUSTOM_ERROR_CODE')

// or create an HTTP error by passing all arguments to the constructor
throw new HttpError('Request validation failed', 400, 'E_YOUR_CUSTOM_ERROR_CODE')

```


## Contributing
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊

1.  Create a fork
2.  Create your feature branch: `git checkout -b my-feature`
3.  Commit your changes: `git commit -am 'Add some feature'`
4.  Push to the branch: `git push origin my-new-feature`
5.  Submit a pull request 🚀


## License
MIT © [Supercharge](https://superchargejs.com)

---

> [superchargejs.com](https://superchargejs.com) &nbsp;&middot;&nbsp;
> GitHub [@supercharge](https://github.com/supercharge) &nbsp;&middot;&nbsp;
> Twitter [@superchargejs](https://twitter.com/superchargejs)
npm package: @supercharge/eslint-config
Description: A shareable ESLint config for JavaScript projects
Author: Marcus Pöhls
Latest version: 3.0.1

# @supercharge/eslint-config
A shareable ESLint config for JavaScript projects.


## Installation

```bash
npm i -D eslint@8 @supercharge/eslint-config
```


### Compatibility
| `eslint` | `@supercharge/eslint-config`            |
| -------- | --------------------------------------- |
| `8.x`    | `1.x`                                   |
| `7.x`    | *not supported*                         |


## Usage
Then extend the `@supercharge` ESLint config. This is a shortcut for `@supercharge/eslint-config` which ESLint automatically resolves:

**`.eslintrc.js`**

```js
module.exports = {
  extends: '@supercharge'
}
```


## Related

- [@supercharge/eslint-config-typescript](https://github.com/supercharge/eslint-config-typescript) - ESLint config for TypeScript projects
npm package: @supercharge/eslint-config-typescript
Description: A Shareable ESLint Config for Supercharge Projects using TypeScript
Author: Marcus Pöhls
Latest version: 4.0.2

# @supercharge/eslint-config-typescript
A shareable ESLint config for projects using TypeScript.


## Installation

```bash
npm i -D eslint@8 @supercharge/eslint-config-typescript
```


### Compatibility
| `eslint` | `@supercharge/eslint-config-typescript` |
| -------- | --------------------------------------- |
| `8.x`    | `>=2.x`                                   |
| `7.x`    | `1.x`                                   |


## Usage
Update your ESLint configuration file (for example the `.eslintrc.js` file) and extend `@supercharge/typescript`:

**`.eslintrc.js`**

```js
module.exports = {
  extends: '@supercharge/typescript'
}
```


## Related

- [@supercharge/eslint-config](https://github.com/supercharge/eslint-config) - ESLint config for JavaScript projects