{"id":13396820,"url":"https://github.com/jonschlinkert/fill-range","last_synced_at":"2025-04-13T00:41:28.365Z","repository":{"id":51087576,"uuid":"27113310","full_name":"jonschlinkert/fill-range","owner":"jonschlinkert","description":"Fill in a range of numbers or letters, positive or negative, optionally passing an increment or multiplier to use.","archived":false,"fork":false,"pushed_at":"2024-07-26T14:46:41.000Z","size":146,"stargazers_count":59,"open_issues_count":6,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-07T19:03:34.008Z","etag":null,"topics":["capture","expand","fill","increment","letters","micromatch","numbers","range","regex-range","sequence","step"],"latest_commit_sha":null,"homepage":null,"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/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","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},"funding":{"github":"jonschlinkert"}},"created_at":"2014-11-25T06:59:50.000Z","updated_at":"2025-04-07T01:10:33.000Z","dependencies_parsed_at":"2024-12-13T19:08:51.066Z","dependency_job_id":"8825c849-4109-491d-b249-fbebdcaa8c43","html_url":"https://github.com/jonschlinkert/fill-range","commit_stats":{"total_commits":132,"total_committers":6,"mean_commits":22.0,"dds":0.0757575757575758,"last_synced_commit":"bef65700633e1a9debb1ce67bf2922731c9ef4b5"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffill-range","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffill-range/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffill-range/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Ffill-range/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/fill-range/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248637775,"owners_count":21137538,"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":["capture","expand","fill","increment","letters","micromatch","numbers","range","regex-range","sequence","step"],"created_at":"2024-07-30T18:01:03.850Z","updated_at":"2025-04-13T00:41:28.337Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":["https://github.com/sponsors/jonschlinkert","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68","https://patreon.com/invite/bxpbvm)!","https://www.patreon.com/jonschlinkert"],"categories":["字符串","JavaScript"],"sub_categories":[],"readme":"# fill-range [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=W8YFZ425KND68) [![NPM version](https://img.shields.io/npm/v/fill-range.svg?style=flat)](https://www.npmjs.com/package/fill-range) [![NPM monthly downloads](https://img.shields.io/npm/dm/fill-range.svg?style=flat)](https://npmjs.org/package/fill-range) [![NPM total downloads](https://img.shields.io/npm/dt/fill-range.svg?style=flat)](https://npmjs.org/package/fill-range) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/fill-range.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/fill-range)\n\n\u003e Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save fill-range\n```\n\n## Usage\n\nExpands numbers and letters, optionally using a `step` as the last argument. _(Numbers may be defined as JavaScript numbers or strings)_.\n\n```js\nconst fill = require('fill-range');\n// fill(from, to[, step, options]);\n\nconsole.log(fill('1', '10')); //=\u003e ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']\nconsole.log(fill('1', '10', { toRegex: true })); //=\u003e [1-9]|10\n```\n\n**Params**\n\n* `from`: **{String|Number}** the number or letter to start with\n* `to`: **{String|Number}** the number or letter to end with\n* `step`: **{String|Number|Object|Function}** Optionally pass a [step](#optionsstep) to use.\n* `options`: **{Object|Function}**: See all available [options](#options)\n\n## Examples\n\nBy default, an array of values is returned.\n\n**Alphabetical ranges**\n\n```js\nconsole.log(fill('a', 'e')); //=\u003e ['a', 'b', 'c', 'd', 'e']\nconsole.log(fill('A', 'E')); //=\u003e [ 'A', 'B', 'C', 'D', 'E' ]\n```\n\n**Numerical ranges**\n\nNumbers can be defined as actual numbers or strings.\n\n```js\nconsole.log(fill(1, 5));     //=\u003e [ 1, 2, 3, 4, 5 ]\nconsole.log(fill('1', '5')); //=\u003e [ 1, 2, 3, 4, 5 ]\n```\n\n**Negative ranges**\n\nNumbers can be defined as actual numbers or strings.\n\n```js\nconsole.log(fill('-5', '-1')); //=\u003e [ '-5', '-4', '-3', '-2', '-1' ]\nconsole.log(fill('-5', '5')); //=\u003e [ '-5', '-4', '-3', '-2', '-1', '0', '1', '2', '3', '4', '5' ]\n```\n\n**Steps (increments)**\n\n```js\n// numerical ranges with increments\nconsole.log(fill('0', '25', 4)); //=\u003e [ '0', '4', '8', '12', '16', '20', '24' ]\nconsole.log(fill('0', '25', 5)); //=\u003e [ '0', '5', '10', '15', '20', '25' ]\nconsole.log(fill('0', '25', 6)); //=\u003e [ '0', '6', '12', '18', '24' ]\n\n// alphabetical ranges with increments\nconsole.log(fill('a', 'z', 4)); //=\u003e [ 'a', 'e', 'i', 'm', 'q', 'u', 'y' ]\nconsole.log(fill('a', 'z', 5)); //=\u003e [ 'a', 'f', 'k', 'p', 'u', 'z' ]\nconsole.log(fill('a', 'z', 6)); //=\u003e [ 'a', 'g', 'm', 's', 'y' ]\n```\n\n## Options\n\n### options.step\n\n**Type**: `number` (formatted as a string or number)\n\n**Default**: `undefined`\n\n**Description**: The increment to use for the range. Can be used with letters or numbers.\n\n**Example(s)**\n\n```js\n// numbers\nconsole.log(fill('1', '10', 2)); //=\u003e [ '1', '3', '5', '7', '9' ]\nconsole.log(fill('1', '10', 3)); //=\u003e [ '1', '4', '7', '10' ]\nconsole.log(fill('1', '10', 4)); //=\u003e [ '1', '5', '9' ]\n\n// letters\nconsole.log(fill('a', 'z', 5)); //=\u003e [ 'a', 'f', 'k', 'p', 'u', 'z' ]\nconsole.log(fill('a', 'z', 7)); //=\u003e [ 'a', 'h', 'o', 'v' ]\nconsole.log(fill('a', 'z', 9)); //=\u003e [ 'a', 'j', 's' ]\n```\n\n### options.strictRanges\n\n**Type**: `boolean`\n\n**Default**: `false`\n\n**Description**: By default, `null` is returned when an invalid range is passed. Enable this option to throw a `RangeError` on invalid ranges.\n\n**Example(s)**\n\nThe following are all invalid:\n\n```js\nfill('1.1', '2');   // decimals not supported in ranges\nfill('a', '2');     // incompatible range values\nfill(1, 10, 'foo'); // invalid \"step\" argument\n```\n\n### options.stringify\n\n**Type**: `boolean`\n\n**Default**: `undefined`\n\n**Description**: Cast all returned values to strings. By default, integers are returned as numbers.\n\n**Example(s)**\n\n```js\nconsole.log(fill(1, 5));                    //=\u003e [ 1, 2, 3, 4, 5 ]\nconsole.log(fill(1, 5, { stringify: true })); //=\u003e [ '1', '2', '3', '4', '5' ]\n```\n\n### options.toRegex\n\n**Type**: `boolean`\n\n**Default**: `undefined`\n\n**Description**: Create a regex-compatible source string, instead of expanding values to an array.\n\n**Example(s)**\n\n```js\n// alphabetical range\nconsole.log(fill('a', 'e', { toRegex: true })); //=\u003e '[a-e]'\n// alphabetical with step\nconsole.log(fill('a', 'z', 3, { toRegex: true })); //=\u003e 'a|d|g|j|m|p|s|v|y'\n// numerical range\nconsole.log(fill('1', '100', { toRegex: true })); //=\u003e '[1-9]|[1-9][0-9]|100'\n// numerical range with zero padding\nconsole.log(fill('000001', '100000', { toRegex: true }));\n//=\u003e '0{5}[1-9]|0{4}[1-9][0-9]|0{3}[1-9][0-9]{2}|0{2}[1-9][0-9]{3}|0[1-9][0-9]{4}|100000'\n```\n\n### options.transform\n\n**Type**: `function`\n\n**Default**: `undefined`\n\n**Description**: Customize each value in the returned array (or [string](#optionstoRegex)). _(you can also pass this function as the last argument to `fill()`)_.\n\n**Example(s)**\n\n```js\n// add zero padding\nconsole.log(fill(1, 5, value =\u003e String(value).padStart(4, '0')));\n//=\u003e ['0001', '0002', '0003', '0004', '0005']\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Contributors\n\n| **Commits** | **Contributor** |  \n| --- | --- |  \n| 116 | [jonschlinkert](https://github.com/jonschlinkert) |  \n| 4   | [paulmillr](https://github.com/paulmillr) |  \n| 2   | [realityking](https://github.com/realityking) |  \n| 2   | [bluelovers](https://github.com/bluelovers) |  \n| 1   | [edorivai](https://github.com/edorivai) |  \n| 1   | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |  \n\n### Author\n\n**Jon Schlinkert**\n\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n\nPlease consider supporting me on Patreon, or [start your own Patreon page](https://patreon.com/invite/bxpbvm)!\n\n\u003ca href=\"https://www.patreon.com/jonschlinkert\"\u003e\n\u003cimg src=\"https://c5.patreon.com/external/logo/become_a_patron_button@2x.png\" height=\"50\"\u003e\n\u003c/a\u003e\n\n### License\n\nCopyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on April 08, 2019._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Ffill-range","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Ffill-range","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Ffill-range/lists"}