open-index/open-npm huggingface dataset:
npm package: @reverse/encoder
Description: Encodes values into a string.
Latest version: 1.2.10

# @reverse/encoder

> Encodes values into a randomly generated string.

Generates random identifiers for input strings, the same input string will be the same output
string (cached, not hashing). Used in some Reverse Squared projects for generating Error Codes
that we can decode but outsiders without access will not be able to.

## Install

```
npm install @reverse/encoder
```

---

## Usage

### Encoding Values

Use the `encode()` function to encode a value. It returns the code that you will have to decode.

```js
import { encode } from '@reverse/encoder';

encode('Hello!');
// Example Output: "91887D"
```

If you encode the same value twice, the returned code will be the same as the first time you encoded that value.

### Decoding Values

To decode the value, use the `decode()` function. It will return the original value that you encoded.

```js
import { decode } from '@reverse/encoder';

// Assuming we use the same code in the above example.
decode('91887D');
// "Hello!"
```

### Custom Identifier Generator

This module also exposes two functions for using the ID generator.

```js
import { setIDGenerator } from '@reverse/encoder';

generateID(); // -> "123456" Example ID from default generator.

setIDGenerator(() => 'Hello'); // All generated IDs will be "Hello",
// this will crash the application after
// encoding two separate values.

generateID(); // -> "Hello"
```
npm package: @reverse/random
Description: Easy random generation.
Latest version: 1.0.12

# @reverse/random

> Easy random generation.

You can install with nodejs and npm

```
npm i @reverse/random
```

## Table of Contents

- [randomInt](#randomIntmin-max)
- [chance](#chancepercent)
- [randomOf](#randomOflist)
- [randomList](#randomListlist-items-requiredValues)

## Usage

### randomInt(min, max)

> Generates a random whole number between two values.

#### Parameters

- `min: Number`: The minimum number to generate inclusivly.
- `max: Number`: The maximum number to generate inclusivly.

#### Example

```js
import { randomInt } from '@reverse/random';

randomInt(1, 5);
// Example Output: 5
```

### chance(percent)

> Returns true a percent amount of the time.

#### Parameters

- `percent: Number`: The percent chance to return true.

#### Example

```js
import { chance } from '@reverse/random';

chance(100);
// true

chance(0);
// false

chance(50);
// Example Output: true
```

### randomOf(list)

> Returns a random element from an array.

#### Parameters

- `list: Array`: The array to pick from.

#### Example

```js
import { randomOf } from '@reverse/random';

randomOf([1, 2, 3]);
// Example Output: 2
```

### randomList(list, items, requiredValues)

> Picks multiple values from an array.

#### Parameters

- `list: Array`: The array to choose from.
- `items: Number`: How many items should be returned. Default 1.
- `requiredValues: Array`: The values that have to be in the returned items. Default [].

#### Example

```js
import { randomList } from '@reverse/random';

randomList([1, 2, 3, 4], 1, []);
// Exanple Output: [3]

randomList([1, 2, 3, 4], 2, []);
// Exanple Output: [1, 3]

randomList([1, 2, 3, 4], 3, [3]);
// Exanple Output: [3, 3, 3]
```