{"id":16485560,"url":"https://github.com/kdby-io/range-shuffle","last_synced_at":"2025-04-04T17:49:20.032Z","repository":{"id":65371916,"uuid":"91626772","full_name":"kdby-io/range-shuffle","owner":"kdby-io","description":"Wide-range integer shuffler","archived":false,"fork":false,"pushed_at":"2020-03-29T05:30:22.000Z","size":1053,"stargazers_count":1,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T20:50:58.744Z","etag":null,"topics":["lcg","random","range","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/kdby-io.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":"2017-05-17T22:50:18.000Z","updated_at":"2018-11-17T01:40:14.000Z","dependencies_parsed_at":"2023-01-20T01:32:18.251Z","dependency_job_id":null,"html_url":"https://github.com/kdby-io/range-shuffle","commit_stats":null,"previous_names":["pueue/range-shuffle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdby-io%2Frange-shuffle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdby-io%2Frange-shuffle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdby-io%2Frange-shuffle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kdby-io%2Frange-shuffle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kdby-io","download_url":"https://codeload.github.com/kdby-io/range-shuffle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247226195,"owners_count":20904465,"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":["lcg","random","range","shuffle"],"created_at":"2024-10-11T13:26:16.852Z","updated_at":"2025-04-04T17:49:20.012Z","avatar_url":"https://github.com/kdby-io.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Range-Shuffle [![Build Status](https://img.shields.io/travis/pueue/range-shuffle.svg?style=flat-square)](https://travis-ci.org/pueue/range-shuffle) [![Version](https://img.shields.io/npm/v/range-shuffle.svg?style=flat-square)](https://www.npmjs.com/package/range-shuffle) [![Download](https://img.shields.io/npm/dt/range-shuffle.svg?style=flat-square)](https://www.npmjs.com/package/range-shuffle) [![Greenkeeper badge](https://badges.greenkeeper.io/pueue/range-shuffle.svg)](https://greenkeeper.io/)\n\nWide-range integer shuffler.\n\n## Goals\n\n- No array\n- Reversible\n\n## Getting Started\n\n### Install\n\n```sh\nnpm install --save range-shuffle\n```\n\n### Usage\n\n```javascript\nconst Shuffler = require('range-shuffle');\n// or\nimport Shuffler from 'range-shuffle';\n\nconst rs = new Shuffler({\n  MULTIPLIER: 7, // it must be a prime number\n  INCREMENT: 9,\n  MODULUS: 10,\n});\n\nconst array = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];\nconst shuffled = array.map(int =\u003e rs.LCG(int));\n// [9, 6, 3, 0, 7, 4, 1, 8, 5, 2]\nconst reversed = shuffled.map(int =\u003e rs.reverseLCG(int));\n// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n```\n\n## Principle\n\n[Linear congruential generator](https://en.wikipedia.org/wiki/Linear_congruential_generator)\n\n## Note\n\nAll constants \u0026 method arguments can be both `Number` and `String` type.  \nIf you want to use a large number over `Number.MAX_SAFE_INTEGER`(9007199254740991), use a `String` type input like `.LCG('9999999999999999')`.\n\n## API\n\n### `new Shuffler(constants)`\n\n`constants` is a object that must contain **three constants**:\n\n- `MULTIPLIER`: Must be **a prime number**.\n- `INCREMENT`\n- `MODULUS`: Range for shuffling. `0 ~ (MODULUS - 1)`\n\n### `.LCG(integer)`\n\nPerforms linear congruential generating based on constants.\n\n### `.reverseLCG(integer)`\n\nRestores linear congruential generating based on constants.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdby-io%2Frange-shuffle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkdby-io%2Frange-shuffle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkdby-io%2Frange-shuffle/lists"}