{"id":39073086,"url":"https://github.com/mimshwright/immutable-deck","last_synced_at":"2026-01-17T18:24:07.996Z","repository":{"id":44176477,"uuid":"131160457","full_name":"mimshwright/immutable-deck","owner":"mimshwright","description":null,"archived":false,"fork":false,"pushed_at":"2022-12-03T17:22:57.000Z","size":875,"stargazers_count":0,"open_issues_count":13,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-09T18:19:36.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mimshwright.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-26T13:33:45.000Z","updated_at":"2018-06-26T17:44:53.000Z","dependencies_parsed_at":"2023-01-22T20:46:08.080Z","dependency_job_id":null,"html_url":"https://github.com/mimshwright/immutable-deck","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mimshwright/immutable-deck","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimshwright%2Fimmutable-deck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimshwright%2Fimmutable-deck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimshwright%2Fimmutable-deck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimshwright%2Fimmutable-deck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mimshwright","download_url":"https://codeload.github.com/mimshwright/immutable-deck/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mimshwright%2Fimmutable-deck/sbom","scorecard":{"id":647599,"data":{"date":"2025-08-11","repo":{"name":"github.com/mimshwright/immutable-deck","commit":"48fb97221b126aee5ca6adf2e2a6372e28671c26"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/26 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"84 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-c6rq-rjc2-86v2","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-ff7x-qrg7-qggm","Warn: Project is vulnerable to: GHSA-phwq-j96m-2c2q","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-h726-x36v-rx45","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-fhjf-83wg-r2j9","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-h9rv-jmmf-4pgx","Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94","Warn: Project is vulnerable to: GHSA-4g88-fppr-53pp","Warn: Project is vulnerable to: GHSA-4jqc-8m5r-9rpr","Warn: Project is vulnerable to: GHSA-4rq4-32rv-6wp6","Warn: Project is vulnerable to: GHSA-64g7-mvw6-v9qj","Warn: Project is vulnerable to: GHSA-vx3p-948g-6vhq","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-r628-mhmh-qjhw","Warn: Project is vulnerable to: GHSA-9r2w-394v-53qc","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-qq89-hq3f-393p","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-38fc-wpqx-33j7","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T12:33:07.558Z","repository_id":44176477,"created_at":"2025-08-21T12:33:07.558Z","updated_at":"2025-08-21T12:33:07.558Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28515418,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T17:57:59.192Z","status":"ssl_error","status_checked_at":"2026-01-17T17:57:52.527Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-17T18:24:07.130Z","updated_at":"2026-01-17T18:24:07.967Z","avatar_url":"https://github.com/mimshwright.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# immutable-deck\n\nData structure for representing decks (of cards) based on Immutable.js Stacks.\n\n## Features\n\n- [X] Add elements to the deck\n  - [X] ...to the top,\n  - [X] bottom,\n  - [X] at an arbitrary place,\n  - [X] or at a random place.\n- [X] Draw one or more elements from the deck \n  - [X] ...from the top,\n  - [X] bottom,\n  - [X] or at an arbitrary place,\n  - [X] or at a random place.\n- [X] Move items from one deck to another.\n- [X] Deal an arbitrary number of items from the Deck into an arbitrary number of groups.\n  - [X] ... from the top\n  - [X] from the bottom\n  - [X] deal out all the items in the deck to the groups.\n- [X] Split/cut the deck\n  - [X] ...in half\n  - [X] At an arbitrary point\n- [X] Count the number of items in the deck.\n- [X] Shuffle the contents of the deck.\n- [X] Unshuffle (sort) the contents of the deck.\n- [X] Reverse order of deck.\n- [X] Random methods are deterministic (can be reproduced with the same random seed).\n\n## FAQ\n\n### What about Hands of cards, piles of cards, the river, etc.?\n\nSince there is technically no difference between a hand and a deck the same data structure can be used for both. Therefore, methods like `draw()` return items drawn as a new Deck. \n\n### Can this be used for card games other than the standard deck of cards?\n\nYes. In fact, Deck doesn't make any assumptions about what kind of values you put inside it. You can use strings, numbers, complex card objects, or anything else.\n\n### Why not just mutate the deck? It seems like way more work to create new decks all the time. \n\nImmutability offers [many benefits](https://www.youtube.com/watch?v=Wo0qiGPSV-s) but if you're looking for a mutable version, [card-deck](https://www.npmjs.com/package/card-deck) looks like a pretty good one.\n\n### Where are the card graphics? \n\nThis library is all about organizing the elements (cards) in the deck but it doesn't provide any definition of what the card should be. You will need to define your own way to render the elements inside. \n\n## API\n\nImportant: `Deck` extends [Immutable.Stack](https://facebook.github.io/immutable-js/docs/#/Stack) so be sure to familiarize yourself with Immutable's API. it can do everything that a `Stack` can do plus the following...  \n\n### Basics \n\n#### `size`\nProperty (inherited from Stack). Get the number of itmes in the deck.\n\n##### Example\n```\nconst deck = new Deck([\"a\", \"b\", \"c\"]);\ndeck.size; // 3\n```\n\n#### `get( index )`\n(inherited from Stack). Get the value of the item at the index.\n\n##### Example\n```\nconst deck = new Deck([\"a\", \"b\", \"c\"]);\ndeck.get(1); // \"b\"\n```\n\n#### `set( index, value )`\nSets a value at the given index. \n\n##### Example\n```\nconst deck = new Deck([\"a\", \"😐\", \"c\"]);\ndeck.set(1, \"b\"); // [\"a\", \"b\", \"c\"]\n```\n\n### Adding items to deck\n\nThese functions add one or more items to the deck. Returns a new Deck with the items added. Items which are collections are not automatically flattened, that is, they are added as collections.\n\n#### `addToTop( ...items )`\n_alias `add( ...items )`_\n\n`add()` and `addToTop()` add items to the top (front) of the deck. \n\n##### Example\n```\nconst deck = new Deck([\"c\", \"d\"]);\ndeck.add(\"a\", \"b\"); // [\"a\", \"b\", \"c\", \"d\"]\n\n// Collections are not flattened.\ndeck.add([\"a\", \"b\"]); // [[\"a\", \"b\"], \"c\", \"d\"]\n\n// Use spread to flatten collections.\ndeck.add(...[\"a\", \"b\"]); // [\"a\", \"b\", \"c\", \"d\"]\n```\n\n#### `addToBottom( ...items )`\n\nAdds items to the bottom (back) of the deck.\n\n##### Example\n```\nconst deck = new Deck([\"c\", \"d\"]);\ndeck.addToBottom(\"e\", \"f\"); // [\"c\",\"d\",\"e\",\"f\"]\n```\n\n#### `addAt( index, ...items )`\n\nAdd items at a specific index.\n\n##### Example\n```\nconst deck = new Deck([\"c\", \"d\"]);\ndeck.addAt(1, \"c.5\"); // [\"c\",\"c.5\",\"d\"]\n```\n\n### Drawing items from deck\n\nThese functions remove `n` items from the deck (if `n` is `undefined`, it defaults to `1`). Returns an array whose first element is a Deck of items drawn and the second element is the original Deck without the items drawn.\n\n#### `drawFromTop( n )`\n_alias `draw( n )`_\n\nDraw `n` items from the top (front) of the deck. \n\n##### Example\n```\nconst deck = new Deck([0, 1, 2, 3, 4]);\nconst [hand, newDeck] = deck.draw(3); \nhand; // [0, 1, 2]\nnewDeck; // [3, 4]\n\n// Defaults to drawing 1 item.\ndeck.draw(); // [ [0], [1, 2, 3, 4] ]\n\n// Drawing more items than the size of the deck returns\n// an empty collection for the new deck.\ndeck.draw(1000); // [ [0, 1, 2, 3, 4], [] ]\n```\n\n#### `drawFromBottom( n )`\n\nDraw `n` items from the bottom (back) of the deck.\n\n##### Example\n```\nconst deck = new Deck([0, 1, 2, 3, 4]);\nconst [hand, newDeck] = deck.drawFromBottom(3); \nhand; // [4, 3, 2] note order is reversed\nnewDeck; // [0, 1]\n```\n\n#### `drawFrom( index, n )`\n\nDraw `n` items from a specific index.\n\n##### Example\n```\nconst deck = new Deck([0, 1, 2, 3, 4]);\nconst [hand, newDeck] = deck.drawFrom(1, 3); \nhand; // [1, 2, 3] note order is reversed\nnewDeck; // [0, 4]\n```\n\n### Random\n\n#### `shuffle()`\n\nShuffles the items. Returns a new Deck with elements randomly reordered. \n\n##### Example\n```\nconst deck = new Deck([0, 1, 2, 3, 4, 5]);\ndeck.shuffle(); // Deck([3, 5, 4, 0, 2, 1])\n```\n\n#### `addRandom( ...items )`\n_alias `shuffleInto( ...items )`_\n\nReturns a new deck with one or more values added at random positions. Each item is given a random location in the deck.\n\n##### Example\n```\nlet deck = new Deck([0,1,2,3,4,5,6,7,8,9]);\nlet newDeck = deck.addRandom(\"a\", \"b\", \"c\"); // [0,1,2,3,4,\"a\",5,6,7,\"c\",\"b\",8,9]\n```\n\n#### `drawRandom( n )`\n\nDraw `n` cards from `n` random positions in the deck. A new random position is chosen for each card.\n\n##### Example\n```\nconst deck = new Deck([0, 1, 2, 3, 4]);\nconst [hand, newDeck] = deck.drawRandom(3); \nhand; // [4, 3, 0] note order is random\nnewDeck; // [1, 2]\n```\n\n#### `getRandomIndex()`\n\nReturns a random index in the deck. \n\n##### Example\n```\nconst deck = new Deck([\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\"]);\ndeck.getRandomIndex(); // 1\ndeck.getRandomIndex(); // 5\ndeck.getRandomIndex(); // 3\n```\n\n#### `setRandomSeed( seed? )`\n\nAll randomized functions use a special deterministic random number generator, [random-seed](https://github.com/skratchdot/random-seed). This allows you to produce repeatable sequences of random numbers that guarantee the same order of random numbers when you use the same seed. This is useful for testing or, for example, if you want to have a global challenge mode in a card game where the cards are shuffled identically for every player. \n\n`setRandomSeed()` sets the random seed for the random number sequence used by functions like `shuffle()`. Set to a constant value to create the same sequence of random numbers every time your app is run. Set to undefined to create an unpredictable sequence. See [random-seed](https://github.com/skratchdot/random-seed) for more details.\n\nYou don't need to call `setRandomSeed()` to use the other functions. By default, the random seed is a random value.\n\n##### Example\n```\nlet numbers = new Deck([0,1,2,3,4,5]);\n// Set a random seed.\nnumbers.setRandomSeed(1);\nnumbers.shuffle(); // [ 5, 2, 4, 0, 3, 1 ]\nnumbers.shuffle(); // [ 3, 2, 5, 1, 0, 4 ]\nnumbers.shuffle(); // [ 2, 4, 1, 0, 5, 3 ]\n\n// Set the random seed again to repeat the sequence.\nnumbers.setRandomSeed(1);\nnumbers.shuffle(); // [ 5, 2, 4, 0, 3, 1 ]\nnumbers.shuffle(); // [ 3, 2, 5, 1, 0, 4 ]\nnumbers.shuffle(); // [ 2, 4, 1, 0, 5, 3 ]\n\n// Set to a different seed to change the sequence.\nnumbers.setRandomSeed(2);\nnumbers.shuffle(); // [ 5, 0, 1, 2, 3, 4 ]\n\n// Use undefined to use a random sequence\nnumbers.setRandomSeed();\nnumbers.shuffle(); // [ 4, 2, 0, 1, 5, 3 ]\nnumbers.setRandomSeed();\nnumbers.shuffle(); // [ 1, 0, 3, 5, 2, 4 ]\nnumbers.setRandomSeed();\nnumbers.shuffle(); // [ 5, 2, 0, 1, 3, 4 ]\n```\n\n### Dealing\n\nThese funcitons distribute the elements of a deck into one or more groups in a cyclical fashion, in other words, they deal out the elements like cards. You can specify the number of groups (hands) to deal out and the number of items to deal to each group. If `itemsPerGroup` is undefined, all remaining items are dealt (this may result in some groups having 1 more item than other groups). \n\nResults are returned as an array with the last element being the new deck and the remaining elements being the groups. \n\n#### `dealFromTop( groups, itemsPerGroup? )` \n_alias `deal( groups, itemsPerGroup )`_\n\nDeals from the top (front) of the deck. \n\n##### Example\n```\nlet hand0, hand1, hand2, newDeck;\nlet deck = new Deck([0,1,2,3,4,5,6,7,8,9]);\n\n// Deal 3 cards to 2 hands\n[hand0, hand1, newDeck] = deck.deal(2, 3);\nhand0; // [0, 2, 4]\nhand1; // [1, 3, 5]\nnewDeck; // [6, 7, 8, 9]\n\n// Deal all cards to 3 hands\n[hand0, hand1, hand2, newDeck] = deck.deal(3);\nhand0; // [0, 3, 6, 9]\nhand1; // [1, 4, 7]\nhand2; // [2, 5, 8]\nnewDeck; // []\n```\n\n#### `dealFromBottom( groups, itemsPerGroup? )` \n\nDeals from the bottom (back) of the deck. \n\n##### Example\n```\nlet deck = new Deck([0,1,2,3,4,5,6,7,8,9]);\ndeck.dealFromBottom(2,2); // [ [9, 7], [8, 6], [0, 1, 2, 3, 4, 5] ]\n```\n\n### Other\n\n#### `cut( index? )`\n_alias `split( index )`_\n\nSplits the deck into two decks. If index is `undefined`, the deck is split right down the middle (if there are an odd number of items, the extra item is added to the first deck).\n\nReturns an array containing two deck objects.\n\n##### Example\n```\nconst deck = new Deck([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);\ndeck.cut(); // [ [0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10] ]\ndeck.cut(3); // [ [0, 1, 2], [3, 4, 5, 6, 7, 8, 9, 10] ]\n```\n\n\n## Contributing\n\nIf you'd like to make this project better, here are ways you can help.\n\n- Give your feedback\n- Log bugs\n- Fix bugs\n- Suggest a feature\n- Improve the documentation\n- Improve the examples\n\n### Contributors\n\n- [Mims H. Wright](http://mimswright.com) - Owner\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmimshwright%2Fimmutable-deck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmimshwright%2Fimmutable-deck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmimshwright%2Fimmutable-deck/lists"}