npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scramby

v0.2.0

Published

Generates scrambles for twisty puzzles.

Downloads

221

Readme

scramby

An npm module for generating random-state scrambles for twisty puzzles.

Installation

npm install scramby

Usage

import scramby from 'scramby'
const scrambler = scramby()

console.log(scrambler.getRandomScramble().scrambleString) // L2 U R2 B' R' B' L F2 D2 B D2 F D R2 U F2 R2 U' R2 F'

API

scramby([puzzle])

Creates a scrambler that can be used to generate random scrambles.

Params

  • {string} puzzle - The type of puzzle.
    • Valid types: '222', '333', '444', '555', '666', or '777'
    • default: '333'

Returns:

A Scrambler object.

Example:

import scramby from 'scramby'
const scrambler5x5 = scramby('555')

scrambler.getRandomScramble()

Generates a random scramble.

Returns:

A Scramble object that has a state and a scrambleString. An example structure:

{
  "state": "FRDFUBRFDBDRRRRRBBULLDFBLUUUFFUDLBFLDRBULLRBFFDLUBLUDD",
  "scrambleString": "L2 D2 L2 F2 D2 B' U2 L2 F' D2 B' R' F' U' L' D2 B' U2 B D' U"
}

The state is only needed if you want to draw the scramble.

Example:

import scramby from 'scramby'
const scrambler = scramby()

const { scrambleString } = scrambler.getRandomScramble()
console.log(scrambleString) // L2 D2 L2 F2 D2 B' U2 L2 F' D2 B' R' F' U' L' D2 B' U2 B D' U

scrambler.drawScramble(el, state, width, height)

Draws the scramble to an HTML Element.

Params

  • HTMLElement el - The element to draw to.
  • string state - The state received from getRandomScramble().
  • number width - The desired width for the drawing.
  • number height - The desired height for the drawing.

Example:

import scramby from 'scramby'
const scrambler = scramby()

const { state } = scrambler.getRandomScramble()
scrambler.drawScramble(document.getElementById('my-el'), state, 300, 180)

Output:

CLI

Usage
  $ scramby [options]

Options
  --puzzle, -p  Specify which puzzle you want a scramble for (222 - 777).
  --count, -c  The amount of scrambles you want.

Examples
  $ scramby
  F  L2 B' D2 F' R2 U2 F' L2 B2 F' R' F' R' D  R' D  R  U  F' R

  $ scramby -c 2
  F' D2 B  L2 F  D2 U2 B  F2 U2 F  L  F  U2 R  D2 U' R  B  L2 F'
  U2 R' D2 L' F2 D2 L  D2 F2 D2 L  B' D  U2 B2 L  F  L  B  R  U'

  $ scramby -p 222 -c 2
  F  U  F' U2 R  U  F  R' F
  U' R' U  R  F  R' F2 R'

Running the examples

First, do:

npm run build:examples

Then open up the index.html file for the example you want to see.

Credits

This is a fork of jsss in the form of an npm module. It's been modified to not require a global dependency of Raphael and it can work both in Node and on the browser.

License

Uncertain. Read this for more details.