{"id":19560651,"url":"https://github.com/zoubin/array-permutation","last_synced_at":"2025-09-05T10:32:55.998Z","repository":{"id":32304063,"uuid":"35879085","full_name":"zoubin/array-permutation","owner":"zoubin","description":"permutation util","archived":false,"fork":false,"pushed_at":"2017-06-07T02:08:50.000Z","size":9,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-29T05:45:45.502Z","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/zoubin.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","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":"2015-05-19T11:52:32.000Z","updated_at":"2019-03-11T12:05:49.000Z","dependencies_parsed_at":"2022-08-23T01:31:10.606Z","dependency_job_id":null,"html_url":"https://github.com/zoubin/array-permutation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/zoubin/array-permutation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Farray-permutation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Farray-permutation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Farray-permutation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Farray-permutation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zoubin","download_url":"https://codeload.github.com/zoubin/array-permutation/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zoubin%2Farray-permutation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273648053,"owners_count":25143627,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-11T05:08:23.395Z","updated_at":"2025-09-05T10:32:50.968Z","avatar_url":"https://github.com/zoubin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# array-permutation\npermutation utils. Return `Iterable` for iterating all permutations of an array.\n\n## Usage\n\n```javascript\nvar permutation = require('array-permutation');\nvar range = permutation.range;\nvar random = permutation.random;\nvar shuffle = permutation.shuffle;\n```\n### range(n)\n\nReturn [0,..,n-1]\n\n### range(low, high, step)\n\nReturn [low, low + step, low + 2 * step,..., low + k * step], with `low + k * step \u003c high`\n\n### random(n)\n\nReturn an array populated with a random permutation of `range(n)`\n\n### random(low, high, step)\n\nReturn an array populated with a random permutation of `range(low, high, step)`\n\n### permutation(n)\n\nReturn an iterable, for iterating all permutations of `range(n)`\n\n### permutation(low, high, step)\n\nReturn an iterable, for iterating all permutations of `range(low, high, step)`\n\n### permutation([])\n\nReturn an iterable, for iterating all permutations of the given array.\n\n### shuffle([])\n\nShuffle the given array, and return it.\n\n## Example\n\n### permutation\n\n```javascript\nvar perm = require('..');\nvar iter = perm([1, 2, 3, 4]);\nfor (var p of iter) {\n    console.log(p);\n}\n\n```\n\noutput:\n\n```\n⌘ node example/permutation.js\n[ 1, 2, 3, 4 ]\n[ 2, 1, 3, 4 ]\n[ 2, 3, 1, 4 ]\n[ 2, 3, 4, 1 ]\n[ 1, 3, 2, 4 ]\n[ 3, 1, 2, 4 ]\n[ 3, 2, 1, 4 ]\n[ 3, 2, 4, 1 ]\n[ 1, 3, 4, 2 ]\n[ 3, 1, 4, 2 ]\n[ 3, 4, 1, 2 ]\n[ 3, 4, 2, 1 ]\n[ 1, 2, 4, 3 ]\n[ 2, 1, 4, 3 ]\n[ 2, 4, 1, 3 ]\n[ 2, 4, 3, 1 ]\n[ 1, 4, 2, 3 ]\n[ 4, 1, 2, 3 ]\n[ 4, 2, 1, 3 ]\n[ 4, 2, 3, 1 ]\n[ 1, 4, 3, 2 ]\n[ 4, 1, 3, 2 ]\n[ 4, 3, 1, 2 ]\n[ 4, 3, 2, 1 ]\n```\n\n### random\n\n```javascript\nvar random = require('..').random;\n\nconsole.log(random(5));                 // [ 3, 2, 4, 1, 0  ]\nconsole.log(random(2, 5));              // [ 4, 3, 2  ]\nconsole.log(random(1, 5, 2));           // [ 3, 1  ]\nconsole.log(random([1, 2, 3, 4, 5]));   // [ 4, 5, 3, 1, 2  ]\n```\n\noutput:\n\n```\n⌘ node example/random.js\n[ 4, 0, 1, 2, 3 ]\n[ 4, 2, 3 ]\n[ 3, 1 ]\n[ 3, 4, 1, 5, 2 ]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Farray-permutation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzoubin%2Farray-permutation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzoubin%2Farray-permutation/lists"}