Nutritious Pumpkin Masses

    scramble-generator

    0.2.2 • Public • Published

    scramble-generator npm

    npm install scramble-generator
    

    0.2.0 has breaking changes. If you're using < v0.2.0, see the upgrading section.

    API

    generateScramble

    Generates a random scramble for the given cube size.

    Parameters

    • $0 any (optional, default {})
      • $0.cubeSize (optional, default 3)
      • $0.length (optional, default (cubeSize-2)*20||8)
      • $0.formatted (optional, default true)

    Examples

    import generateScramble from 'scramble-generator';
    generateScramble();
    // R' U F D' L ...
     
    generateScramble({ cubeSize: 3, formatted: false });
    // [ { face: 'U', inverted: false, double: true },
    // { face: 'R', inverted: true, double: false },
    // { face: 'D', inverted: false, double: true }, ... ]

    Returns (string | Array<Move>)

    formatScramble

    Formats a given scramble as a string.

    Parameters

    • scramble Array<Move> List of Move objects representing a scramble to be formatted.

    Examples

    import { formatScramble } from 'scramble-generator';
    import { Faces } from 'scramble-utils-common';
    format([{
      face: Faces.R,
      inverted: true
    }, {
      face: Faces.U,
      double: true
    }, {
      face: Faces.L
    }])
    // "R' U2 L"

    Returns string String representation of the given scramble.

    Upgrading

    From v0.1.x

    v0.2.0 has breaking changes. To upgrade from an earlier version:

    // Before:
    import { formatted, generate, format, parse } from 'scramble-generator';
     
    formatted(); // R U' D ...
    const scramble = generate(); // [{ face: 'R', longFace: 'RIGHT', inverted: true, double: false }, ...]
    format(scramble) // R' ...
    parse("R' U L") // [{ face: 'R', longFace: 'RIGHT', inverted: true, double: false }, ...]
     
    // After
    import generateScramble, { formatScramble } from 'scramble-generator';
    import parseScramble from 'scramble-parser';
     
    generateScramble(); // R U' D ...
    const scramble = generateScramble({ formatted: false }); // [{ face: 'R', inverted: true, double: false }, ...] (NB: `longFace` has been removed)
    formatScramble(scramble); // R' ...
    parseScramble("R' U L"); // [{ face: 'R', inverted: true, double: false }, ...] (NB: `longFace` has been removed)

    These breaking changes are necessary to facilitate moving towards v1.0.0, after which the package will adhere strictly to semver. There might be some more breaking changes

    Install

    npm i scramble-generator

    DownloadsWeekly Downloads

    0

    Version

    0.2.2

    License

    MIT

    Last publish

    Collaborators

    • msrose