{"id":18576082,"url":"https://github.com/thiagodp/shuffle-obj-arrays","last_synced_at":"2025-05-16T00:34:45.085Z","repository":{"id":57359044,"uuid":"129017254","full_name":"thiagodp/shuffle-obj-arrays","owner":"thiagodp","description":"Shuffles the arrays of the given (object) map","archived":false,"fork":false,"pushed_at":"2020-07-05T01:38:03.000Z","size":132,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-21T15:17:21.675Z","etag":null,"topics":["array","map","object","prng","random","rng","shuffle"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thiagodp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-11T01:40:38.000Z","updated_at":"2020-07-05T01:38:05.000Z","dependencies_parsed_at":"2022-09-06T22:21:56.226Z","dependency_job_id":null,"html_url":"https://github.com/thiagodp/shuffle-obj-arrays","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fshuffle-obj-arrays","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fshuffle-obj-arrays/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fshuffle-obj-arrays/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thiagodp%2Fshuffle-obj-arrays/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thiagodp","download_url":"https://codeload.github.com/thiagodp/shuffle-obj-arrays/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254447893,"owners_count":22072755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["array","map","object","prng","random","rng","shuffle"],"created_at":"2024-11-06T23:23:32.549Z","updated_at":"2025-05-16T00:34:45.042Z","avatar_url":"https://github.com/thiagodp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shuffle-obj-arrays\n\n[![Version](https://img.shields.io/npm/v/shuffle-obj-arrays)](https://img.shields.io/npm/v/shuffle-obj-arrays?label=Version)\n[![Build Status](https://travis-ci.org/thiagodp/shuffle-obj-arrays.svg?branch=master)](https://travis-ci.org/thiagodp/shuffle-obj-arrays)\n[![Known Vulnerabilities](https://snyk.io/test/github/thiagodp/shuffle-obj-arrays/badge.svg?targetFile=package.json)](https://snyk.io/test/github/thiagodp/shuffle-obj-arrays?targetFile=package.json)\n\n\u003e Shuffles the arrays of the given (object) map using [shuffle-array](https://github.com/pazguille/shuffle-array).\n\n## Install\n\n```bash\nnpm install shuffle-obj-arrays\n```\n\n## Example\n\n```javascript\nconst shuffleObjArrays = require( 'shuffle-obj-arrays' );\n\nconsole.log(\n\tshuffleObjArrays( {\n\t\t\"foo\": [ \"x\", \"y\" ],\n\t\t\"bar\": [ \"a\", \"b\", \"c\", \"d\" ],\n\t\t\"baz\": [ \"f\", \"g\" ]\n\t} )\n);\n```\nIt will print something like:\n```json\n{\n    \"foo\": [ \"y\", \"x\" ],\n    \"bar\": [ \"c\", \"b\", \"a\", \"d\" ],\n    \"baz\": [ \"g\", \"f\" ]\n}\n```\n\n## Version 1\n\n### API\n\nVersion 1 accepts the same options as [shuffle](https://github.com/pazguille/shuffle-array#shufflearr-options), plus `copyNonArrays`.\n\nSyntax:\n```typescript\nshuffleObjArrays(\n\tobj: object,\n\toptions: { copy: false, copyNonArrays: false },\n\trng: (n: number): number = Math.random\n): object\n```\n\nRandomizes the order of the elements in all arrays of the given object.\n\n- `obj` {object} - The given object.\n- `options` {object} - Options, which may have:\n  - `copy` {boolean} - `true` to copy the given object. Defaults to `false`.\n  - `copyNonArrays` {boolean} - `true` to copy non-array properties of the given object. Only works when `copy` is `true`. Defaults to `false`.\n  - `rng` {function} - Custom random number generator. Defaults to `Math.random`.\n\n### Example:\n\n```javascript\nconst shuffleObjArrays = require( 'shuffle-obj-arrays' );\n\n// Using a external pseudo-random number generator\n// https://github.com/davidbau/seedrandom\nconst seedrandom = require( 'seedrandom' );\n\nconst options = {\n    copy: true,\n    rng: seedrandom( 'my seed' )\n};\n\nconsole.log(\n\tshuffleObjArrays(\n\t\t{\n\t\t\t\"foo\": [ \"x\", \"y\" ],\n\t\t\t\"bar\": [ \"a\", \"b\", \"c\", \"d\" ],\n\t\t\t\"baz\": [ \"f\", \"g\" ],\n\t\t\t\"zoo\": \"non array property\"\n\t\t},\n\t\toptions\n\t)\n);\n```\nIt returns something like:\n```json\n{\n    \"foo\": [ \"y\", \"x\" ],\n    \"bar\": [ \"c\", \"b\", \"a\", \"d\" ],\n    \"baz\": [ \"g\", \"f\" ]\n}\n```\n\n## See also\n\n- [shuffle-array](https://github.com/pazguille/shuffle-array) - Shuffles an array using [Fisher-Yates algorithm](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle) and allows to pass a custom pseudo-random number generator (PRNG)\n- [seedrandom](https://github.com/davidbau/seedrandom) - Predictive PRNG\n- [one-wise](https://github.com/thiagodp/one-wise) - One-wise combinatorial testing for the arrays of the given object.\n\n\n## License\n\n[MIT](LICENSE) © [Thiago Delgado Pinto](https://github.com/thiagodp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagodp%2Fshuffle-obj-arrays","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthiagodp%2Fshuffle-obj-arrays","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthiagodp%2Fshuffle-obj-arrays/lists"}