# scrambled

> A Rubik's cube scrambler API for Node.js.

Latest version **1.0.2** (published 2021-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install scrambled
pnpm add scrambled
yarn add scrambled
bun add scrambled
```

Provides the command `scrambled`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-05-20 |
| First published | 2021-05-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 13.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Zack Pace |
| Maintainers | faztasio |
| Keywords | speedcubing, online |

## Links

- npm: https://www.npmjs.com/package/scrambled
- Repository: https://github.com/trimorphdev/scrambled
- Homepage: https://github.com/trimorphdev/scrambled#readme
- Issues: https://github.com/trimorphdev/scrambled/issues
- npm.io page: https://npm.io/package/scrambled

## Dependencies (4)

- [yargs](https://npm.io/package/yargs.md) ^17.0.1
- [seedrandom](https://npm.io/package/seedrandom.md) ^3.0.5
- [@types/yargs](https://npm.io/package/@types/yargs.md) ^16.0.2
- [@types/seedrandom](https://npm.io/package/@types/seedrandom.md) ^3.0.0

## Recent versions

- 1.0.2 (latest) — 2021-05-20
- 1.0.1 — 2021-05-20
- 1.0.0 — 2021-05-20

## README

# Scrambled
A NxN Rubik's cube scrambling library for Node.js

```
npm i --save scrambled
```

# Command Line
Scrambled comes packaged with a nifty command line tool:
```sh
scrambled --help
```

## CLI Scramble Generation
```sh
scrambled generate [-s/--size] [-c/--count]
```

This command generates a scramble, with the optional options being:
- `-s/--size`: the size of the Rubik's cube to scramble
- `-c/--count`: the amount of moves the scramble has

## CLI Scramble Verification
```sh
scrambled verify [-s/--scramble] [-t/--token] [-S/--size]
```
Checks if a scramble was generated by Scrambled.

- `-s/--scramble`: **required:** the scramble to check.
- `-t/--token`: **required:** the authentication token provided when the scrambl was generated
- `-S/--size`: **required:** the size of the Rubik's cube to check

# API
## Scrambling
You can scramble a cube using the `scrambled.generateScramble` method:
```js
const scrambled = require('scrambled');

scrambled.generateScramble(30) // Generate scramble with 30 moves
    .then((result) => {
        console.log(result.scramble);
    });
```

## Synchronous Generation
To generate scrambles synchronously, you can use the `scrambled.generateScrambleSync` function.
```js
const scrambled = require('scrambled');

const result = generateScrambleSync(30); // Generate a scramble with 30 moves
console.log(result.scramble);
```

## Arguments
```ts
scramble.generateScramble(count: number, size: number = 3, hash?: string);
```

As you can see, the second argument, `size`, is optional and defaults to a 3x3 Rubik's cube.

If, for example, you want to generate a scramble for a 4x4 Rubik's cube, you can change this argument to 4:
```ts
scramble.generateScramble(30, 4);
```
The first argument is the move count of the scramble, and the second argument is the size of the cube.

The same arguments apply to the `generateScrambleSync` method.

### Seeding
If you want to generate a scramble with your own `seed`, you can provide a 3rd argument, which is a string (keep in mind, you must provide a `size` argument to use a custom seed):
```js
scramble.generateScramble(30, 3, 'my custom seed');
```

## Verification
You can verify if a scramble was generated by Scrambled with the `verifyScramble` and `verifyScrambleSync` methods.

```js
const scrambled = require('scrambled');

const scramble = scramble.generateScrambleSync(30);

scrambled.verifyScramble(scramble.token, scramble.scramble, scramble.size)
    .then((result) => {
        console.log(result); // true or false
    });
```

---
_Source: https://npm.io/package/scrambled · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
