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

create-deck-plus-array-shuffle

v1.0.3

Published

Allow students to create a deck of cards or shuffle any array

Downloads

5

Readme

Create-deck-plus-array-shuffle

This is going to allow any student to install the package and either create a deck of cards that has a value, a suit and the value plus suit combined for display

Install

$ npm install create-deck-plus-array-shuffle

Usage

import exportedFunctions from "create-deck-plus-array-shuffle";

const myDeck = exportedFunctions.createDeckOfCards();

// The following should be the value of myDeck:
/* [
  { value: '2', suit: '♣', combined: '2♣' },
  { value: '2', suit: '♦', combined: '2♦' },
  { value: '2', suit: '♥', combined: '2♥' },
  { value: '2', suit: '♠', combined: '2♠' },
  { value: '3', suit: '♣', combined: '3♣' },
  { value: '3', suit: '♦', combined: '3♦' },
  { value: '3', suit: '♥', combined: '3♥' },
  { value: '3', suit: '♠', combined: '3♠' },
  { value: '4', suit: '♣', combined: '4♣' },
  { value: '4', suit: '♦', combined: '4♦' },
  { value: '4', suit: '♥', combined: '4♥' },
  { value: '4', suit: '♠', combined: '4♠' },
  { value: '5', suit: '♣', combined: '5♣' },
  { value: '5', suit: '♦', combined: '5♦' },
  { value: '5', suit: '♥', combined: '5♥' },
  { value: '5', suit: '♠', combined: '5♠' },
  { value: '6', suit: '♣', combined: '6♣' },
  { value: '6', suit: '♦', combined: '6♦' },
  { value: '6', suit: '♥', combined: '6♥' },
  { value: '6', suit: '♠', combined: '6♠' },
  { value: '7', suit: '♣', combined: '7♣' },
  { value: '7', suit: '♦', combined: '7♦' },
  { value: '7', suit: '♥', combined: '7♥' },
  { value: '7', suit: '♠', combined: '7♠' },
  { value: '8', suit: '♣', combined: '8♣' },
  { value: '8', suit: '♦', combined: '8♦' },
  { value: '8', suit: '♥', combined: '8♥' },
  { value: '8', suit: '♠', combined: '8♠' },
  { value: '9', suit: '♣', combined: '9♣' },
  { value: '9', suit: '♦', combined: '9♦' },
  { value: '9', suit: '♥', combined: '9♥' },
  { value: '9', suit: '♠', combined: '9♠' },
  { value: '10', suit: '♣', combined: '10♣' },
  { value: '10', suit: '♦', combined: '10♦' },
  { value: '10', suit: '♥', combined: '10♥' },
  { value: '10', suit: '♠', combined: '10♠' },
  { value: 'J', suit: '♣', combined: 'J♣' },
  { value: 'J', suit: '♦', combined: 'J♦' },
  { value: 'J', suit: '♥', combined: 'J♥' },
  { value: 'J', suit: '♠', combined: 'J♠' },
  { value: 'Q', suit: '♣', combined: 'Q♣' },
  { value: 'Q', suit: '♦', combined: 'Q♦' },
  { value: 'Q', suit: '♥', combined: 'Q♥' },
  { value: 'Q', suit: '♠', combined: 'Q♠' },
  { value: 'K', suit: '♣', combined: 'K♣' },
  { value: 'K', suit: '♦', combined: 'K♦' },
  { value: 'K', suit: '♥', combined: 'K♥' },
  { value: 'K', suit: '♠', combined: 'K♠' },
  { value: 'A', suit: '♣', combined: 'A♣' },
  { value: 'A', suit: '♦', combined: 'A♦' },
  { value: 'A', suit: '♥', combined: 'A♥' },
  { value: 'A', suit: '♠', combined: 'A♠' }
] */

// The shuffle function works for any input array but for the purposes of this demo with a deck here's a possible output for an input matching shuffled deck:

const shuffledDeck = exportedFunctions.shuffle(myDeck)

/* [
  { value: 'K', suit: '♥', combined: 'K♥' },
  { value: '9', suit: '♥', combined: '9♥' },
  { value: '6', suit: '♣', combined: '6♣' },
  { value: '7', suit: '♦', combined: '7♦' },
  { value: '5', suit: '♠', combined: '5♠' },
  { value: '10', suit: '♥', combined: '10♥' },
  { value: 'A', suit: '♥', combined: 'A♥' },
  { value: '2', suit: '♣', combined: '2♣' },
  { value: '3', suit: '♠', combined: '3♠' },
  { value: '2', suit: '♥', combined: '2♥' },
  { value: '6', suit: '♦', combined: '6♦' },
  { value: '5', suit: '♦', combined: '5♦' },
  { value: '4', suit: '♦', combined: '4♦' },
  { value: '8', suit: '♦', combined: '8♦' },
  { value: '6', suit: '♥', combined: '6♥' },
  { value: '4', suit: '♣', combined: '4♣' },
  { value: '2', suit: '♦', combined: '2♦' },
  { value: '2', suit: '♠', combined: '2♠' },
  { value: 'J', suit: '♦', combined: 'J♦' },
  { value: '10', suit: '♠', combined: '10♠' },
  { value: 'J', suit: '♣', combined: 'J♣' },
  { value: '10', suit: '♦', combined: '10♦' },
  { value: 'Q', suit: '♠', combined: 'Q♠' },
  { value: 'J', suit: '♠', combined: 'J♠' },
  { value: 'A', suit: '♦', combined: 'A♦' },
  { value: '3', suit: '♦', combined: '3♦' },
  { value: 'K', suit: '♠', combined: 'K♠' },
  { value: '7', suit: '♣', combined: '7♣' },
  { value: 'Q', suit: '♥', combined: 'Q♥' },
  { value: '4', suit: '♠', combined: '4♠' },
  { value: '7', suit: '♥', combined: '7♥' },
  { value: '3', suit: '♥', combined: '3♥' },
  { value: '8', suit: '♥', combined: '8♥' },
  { value: 'K', suit: '♦', combined: 'K♦' },
  { value: '5', suit: '♣', combined: '5♣' },
  { value: '4', suit: '♥', combined: '4♥' },
  { value: 'A', suit: '♣', combined: 'A♣' },
  { value: '9', suit: '♣', combined: '9♣' },
  { value: '9', suit: '♦', combined: '9♦' },
  { value: '3', suit: '♣', combined: '3♣' },
  { value: '8', suit: '♠', combined: '8♠' },
  { value: '8', suit: '♣', combined: '8♣' },
  { value: '9', suit: '♠', combined: '9♠' },
  { value: 'J', suit: '♥', combined: 'J♥' },
  { value: '5', suit: '♥', combined: '5♥' },
  { value: 'K', suit: '♣', combined: 'K♣' },
  { value: 'Q', suit: '♣', combined: 'Q♣' },
  { value: '7', suit: '♠', combined: '7♠' },
  { value: 'Q', suit: '♦', combined: 'Q♦' },
  { value: 'A', suit: '♠', combined: 'A♠' },
  { value: '6', suit: '♠', combined: '6♠' },
  { value: '10', suit: '♣', combined: '10♣' }
] */

Please note that you may have to run a local file for Javascript by adding to your package.json so it matches what I have below:

{
  "type": "module",
  "dependencies": {
    "create-deck-plus-array-shuffle": "^1.0.3"
  }
}

And then run the file by using this command in the terminal: node --experimental-modules fileName.js simply overwriting fileName.js to whatever the name of the file you're trying to run is.

Hopefully this helps for all those Javascript developers with experience in Python and other languagues that natively support negative indexing and who love passing in negative indexes or positive indexes to their nested arrays or who have hit errors with passing in strings on accident for indexes to arrays!