{"id":19055340,"url":"https://github.com/dilane3/randnjs","last_synced_at":"2026-06-17T06:32:42.389Z","repository":{"id":115191709,"uuid":"492624733","full_name":"dilane3/randnjs","owner":"dilane3","description":"JavaScript Library that handle some random operation on numbers and arrays","archived":false,"fork":false,"pushed_at":"2022-05-16T17:15:29.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-12T06:03:29.351Z","etag":null,"topics":["choice","generator","number","random"],"latest_commit_sha":null,"homepage":"","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/dilane3.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-05-15T23:09:26.000Z","updated_at":"2025-01-18T11:35:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"a6e03f49-d109-4d4b-a65a-bb8d5945c4c5","html_url":"https://github.com/dilane3/randnjs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dilane3/randnjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilane3%2Frandnjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilane3%2Frandnjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilane3%2Frandnjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilane3%2Frandnjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dilane3","download_url":"https://codeload.github.com/dilane3/randnjs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dilane3%2Frandnjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34437449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"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":["choice","generator","number","random"],"created_at":"2024-11-08T23:44:19.542Z","updated_at":"2026-06-17T06:32:42.383Z","avatar_url":"https://github.com/dilane3.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# randnjs \n\nJavaScript Library that handle some random operations on numbers and arrays 🔥🔥🔥\n\n## Installation \n\nusing **yarn**\n\n```bash\nyarn add randnjs\n```\n\nusing **npm**\n\n```bash\nnpm install randnjs\n```\n\n## Usage \n\n**Randnjs** offers you some magics methods 🌟 to handle random operations.\nSo now we will show you all these methods. Keep reading... 📖\n\n### First step: Importation\n\nYou have to import the library first before using it. Do like this\n\n```javascript\nimport { Random } from 'randnjs'\n```\n\nor\n\n```javascript\nconst { Random } = require('randnjs')\n```\n\n\n### Second step: Use methods\n\n1. **Generate a random number**\n\nFor doing this, you have to use the **generate(min?, max?)** method that **Random** class offers.\n\n```javascript\nimport { Random } from 'randnjs'\n\nconsole.log(Random.generate()) // Output: 100 for example...\n```\n\nThis method can take two optional parameters (min and max values)\n\n**Some parameters**\n\n|Parameters    |Types       |Default value |Required |Description                         |\n|---           |---         |----          |---      |---                                 |\n|min           |number      |0             |no       |Minimum value that can be generated |\n|max           |number      |100000000     |no       |Maximum value that can be generated |\n\nSo now you can specify the min and max value\n\n```javascript\nimport { Random } from 'randnjs'\n\nconsole.log(Random.generate(5, 10)) // Output: 7 for example...\n```\n\n\n2. **Generate a list of numbers**\n\nTo generate a list of numbers, you have to use the **samples(length?, min?, max?)** method on the **Random** class.\nIt takes three optional parameters\n\n**Some parameters**\n\n|Parameters    |Types       |Default value |Required |Description                         |\n|---           |---         |----          |---      |---                                 |\n|length        |number      |1             |no       |Number of elements to generate      |\n|min           |number      |0             |no       |Minimum value that can be generated |\n|max           |number      |100000000     |no       |Maximum value that can be generated |\n\n\n**Examples**\n\n\n```javascript\nimport { Random } from 'randnjs'\n\nconst samples = Random.samples()\n\nconsole.log(samples) // output: [12345] for example\n```\n\n```javascript\nimport { Random } from 'randnjs'\n\nconst samples = Random.samples(5)\n\nconsole.log(samples) // output: [1, 100, 50, 12345, 243] for example\n```\n\n```javascript\nimport { Random } from 'randnjs'\n\nconst samples = Random.samples(5, 1, 10)\n\nconsole.log(samples) // output: [1, 10, 3, 6, 2] for example\n```\n\n\n3. **Choose one element from a list of elements**\n\nTo select randomly one element from a list of element, you have to use the **choice(array)** method that the **Random** class offers.\n\nIt takes one required parameter which is a non empty array of elements. Elements here can be numbers, strings, objects and so on...\n\n**Some parameters**  \n\n|Parameters    |Types       |Default value |Required |Description                                   |\n|---           |---         |----          |---      |---                                           |\n|array         |Array       |-             |yes      |Array of elements where we extract one element|\n\n\n**Examples**\n\n\n```javascript\nimport { Random } from 'randnjs'\n\nconst numbers = [1, 6, 10, 24, 15]\n\nconst randomNumber = Random.choice(numbers)\n\nconsole.log(randomNumber) // Output: 6 for example\n```\n\n```javascript\nimport { Random } from 'randnjs'\n\nconst fruits = ['apple', 'banana', 'orange', 'pineapple', 'watermelon']\n\nconst randomFruit = Random.choice(fruits)\n\nconsole.log(randomFruit) // Output: orange for example\n```\n\nThat's all. \n\nThank you 🙏...","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilane3%2Frandnjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdilane3%2Frandnjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilane3%2Frandnjs/lists"}