{"id":20683980,"url":"https://github.com/ibrahimcesar/easy-ranges-numbers-with-steps","last_synced_at":"2025-04-22T12:32:00.009Z","repository":{"id":47589746,"uuid":"483649877","full_name":"ibrahimcesar/easy-ranges-numbers-with-steps","owner":"ibrahimcesar","description":"Minimal and handy utility to generate ranges of numbers with start, end and optional steps","archived":false,"fork":false,"pushed_at":"2023-01-08T15:53:17.000Z","size":405,"stargazers_count":5,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T12:48:01.993Z","etag":null,"topics":["generators","library","numbers","range","ranges","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/easy-range-numbers-with-steps","language":"TypeScript","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/ibrahimcesar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["ibrahimcesar"]}},"created_at":"2022-04-20T12:41:58.000Z","updated_at":"2023-08-25T17:29:39.000Z","dependencies_parsed_at":"2023-02-08T06:31:32.995Z","dependency_job_id":null,"html_url":"https://github.com/ibrahimcesar/easy-ranges-numbers-with-steps","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimcesar%2Feasy-ranges-numbers-with-steps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimcesar%2Feasy-ranges-numbers-with-steps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimcesar%2Feasy-ranges-numbers-with-steps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibrahimcesar%2Feasy-ranges-numbers-with-steps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibrahimcesar","download_url":"https://codeload.github.com/ibrahimcesar/easy-ranges-numbers-with-steps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250240963,"owners_count":21397895,"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":["generators","library","numbers","range","ranges","typescript"],"created_at":"2024-11-16T22:18:29.067Z","updated_at":"2025-04-22T12:31:59.947Z","avatar_url":"https://github.com/ibrahimcesar.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ibrahimcesar"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \n  ![lilcricket](https://user-images.githubusercontent.com/509054/164233040-8bf65eb0-09f5-4ec3-94f6-50efe6514621.png)\n  \n  # Easy number range numbers with steps\n  \n  [![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.svg?v=101)](https://www.typescriptlang.org/)\n\n[![Version](https://img.shields.io/npm/v/easy-range-numbers-with-steps?label=latest%20version)](https://www.npmjs.com/package/easy-range-numbers-with-steps)\u0026nbsp; \u0026nbsp;\u0026nbsp; \u0026nbsp;![Total Downloads](https://img.shields.io/npm/dt/easy-range-numbers-with-steps?color=%23FF0000\u0026logo=npm)\u0026nbsp; \u0026nbsp;\u0026nbsp; \u0026nbsp;[![License](https://badgen.net/github/license/ibrahimcesar/easy-ranges-numbers-with-steps)](./LICENSE)\u0026nbsp; \u0026nbsp;  \u0026nbsp;![GitHub issues by-label](https://img.shields.io/github/issues/ibrahimcesar/easy-ranges-numbers-with-steps/bug)\n\n \n\u003cp\u003eDeveloped in 🇧🇷 \u003cspan role=\"img\" aria-label=\"Flag for Brazil\"\u003eBrazil\u003c/p\u003e\n  \n\u003c/div\u003e\n\nMinimal and handy utility to generate ranges of numbers with start, end and\noptional steps or jumps!\n\n## Use cases\n\n- You need a simple, straightforward solution to generate numbers for an array\n  to end on a determined number;\n- Your array needs steps between numbers;\n- Your array should be declarative, i.e. end on the defined number. If you\n  explicit ask for 10, 10 should be the last number _unless_:\n  - If you pass and _end_ parameter and is outside of the _step_, it will yield\n    only up to steps you need to ensure the rule, otherwise you would get an\n    result not in the step rule defined.\n\n## Params\n\n| Parameter \t| Description                                                                                                                                                                                                                                                                                                                \t|\n|:---------:\t|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------\t|\n| first     \t| **Required** _Number_ The first parameter defines the limit of the numbers returned. If you want a list from 0 up to x, just pass x. X will be included unless other rules apply.                                                                                                                                          \t|\n| second    \t| _Optional_ _Number_ The second parameter defines the start. As usual all arrays start with the offset from the start, i.e. 0, with this parameter will decide a number that will be the starting point.                                                                                                                    \t|\n| third     \t| _Optional_ _Number_ The thir parameter defines a step rule. This rules that precedence over the first one. If you want to generate numbers until x, with a gap or steps between them of 3, and the end number is greater than the step rule, it will be not returned, but will be used as a limit to the numbers returned. \t|\n\n## How to use\n\nYou always should use with the spread operator.\n\n```js\nimport { range } from \"easy-range-numbers-with-steps\";\n\nconst arrWithEnd = [...range(5)];\n\n// arrWithEnd will be an array, with [0,1,2,3,4,5]\n\nconst arrWithEndAndStart = [...range(5, 10)];\n\n// arrWithEndAndStart will be an array, with [5, 6, 7, 8, 9, 10]\n\nconst arrWithEndAndStartAndStep = [...range(10, 0, 2)];\n\n// arrWithEndAndStart will be an array, with [0, 2, 4, 6, 8, 10]\n\nconst arrWithEndAndStartAndStep2 = [...range(11, 0, 2)];\n\n// arrWithEndAndStart will be an array, with [0, 2, 4, 6, 8, 10]! 11 is the end, but outside of the desired steps!\n```\n\nIf you use directly we'll just get an object with the Symbol and the Generator function. If this is what you want, that's ok! Just an friendly warning if you do not know what this means and you start to get \"errors\" for misuse.\n\n\n```js\nimport { range } from \"easy-range-numbers-with-steps\";\n\nconst arr = range(5);\n\n// You will not get an array! If you do a console.info(arr):\n// { [Symbol(Symbol.iterator)]: [GeneratorFunction: generateRange] }\n```\n\n## Purpose\n\nThis is a minimal lib. No external dependencies, feel free to just copy if necessary to your project. It was created for a specific need and I wanted to share with someone with the same use-cases. Arrays are the bread and butter of web apps and is always handy use helper functions.\n\n### Unit tests\n\n\n\u003cimg width=\"643\" alt=\"Unit Tests\" src=\"https://user-images.githubusercontent.com/509054/164478795-e94413f8-f230-4158-83d3-5d3969136cf6.png\"\u003e\n\n\n## MIT License\n\nCopyright (c) 2020 — 2022 [Ibrahim Cesar](https://ibrahimcesar.cloud)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibrahimcesar%2Feasy-ranges-numbers-with-steps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibrahimcesar%2Feasy-ranges-numbers-with-steps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibrahimcesar%2Feasy-ranges-numbers-with-steps/lists"}