项目原始demo,不改动
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Este repositório está arquivado. Você pode visualizar os arquivos e realizar clone, mas não poderá realizar push nem abrir issues e pull requests.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # expand-range [![NPM version](https://img.shields.io/npm/v/expand-range.svg?style=flat)](https://www.npmjs.com/package/expand-range) [![NPM downloads](https://img.shields.io/npm/dm/expand-range.svg?style=flat)](https://npmjs.org/package/expand-range) [![Build Status](https://img.shields.io/travis/jonschlinkert/expand-range.svg?style=flat)](https://travis-ci.org/jonschlinkert/expand-range)
  2. Fast, bash-like range expansion. Expand a range of numbers or letters, uppercase or lowercase. See the benchmarks. Used by micromatch.
  3. ## Install
  4. Install with [npm](https://www.npmjs.com/):
  5. ```sh
  6. $ npm install expand-range --save
  7. ```
  8. Wraps [fill-range] to do range expansion using `..` separated strings. See [fill-range] for the full list of options and features.
  9. ## Example usage
  10. ```js
  11. var expand = require('expand-range');
  12. ```
  13. **Params**
  14. ```js
  15. expand(start, stop, increment);
  16. ```
  17. * `start`: the number or letter to start with
  18. * `end`: the number or letter to end with
  19. * `increment`: optionally pass the increment to use. works for letters or numbers
  20. **Examples**
  21. ```js
  22. expand('a..e')
  23. //=> ['a', 'b', 'c', 'd', 'e']
  24. expand('a..e..2')
  25. //=> ['a', 'c', 'e']
  26. expand('A..E..2')
  27. //=> ['A', 'C', 'E']
  28. expand('1..3')
  29. //=> ['1', '2', '3']
  30. expand('0..-5')
  31. //=> [ '0', '-1', '-2', '-3', '-4', '-5' ]
  32. expand('-9..9..3')
  33. //=> [ '-9', '-6', '-3', '0', '3', '6', '9' ])
  34. expand('-1..-10..-2')
  35. //=> [ '-1', '-3', '-5', '-7', '-9' ]
  36. expand('1..10..2')
  37. //=> [ '1', '3', '5', '7', '9' ]
  38. ```
  39. ### Custom function
  40. Optionally pass a custom function as the second argument:
  41. ```js
  42. expand('a..e', function (val, isNumber, pad, i) {
  43. if (!isNumber) {
  44. return String.fromCharCode(val) + i;
  45. }
  46. return val;
  47. });
  48. //=> ['a0', 'b1', 'c2', 'd3', 'e4']
  49. ```
  50. ## Benchmarks
  51. ```sh
  52. # benchmark/fixtures/alpha-lower.js (29 bytes)
  53. brace-expansion x 145,653 ops/sec ±0.89% (87 runs sampled)
  54. expand-range x 453,213 ops/sec ±1.66% (85 runs sampled)
  55. minimatch x 152,193 ops/sec ±1.17% (86 runs sampled)
  56. # benchmark/fixtures/alpha-upper.js (29 bytes)
  57. brace-expansion x 149,975 ops/sec ±1.10% (88 runs sampled)
  58. expand-range x 459,390 ops/sec ±1.27% (84 runs sampled)
  59. minimatch x 155,253 ops/sec ±1.25% (88 runs sampled)
  60. # benchmark/fixtures/padded.js (33 bytes)
  61. brace-expansion x 14,694 ops/sec ±1.37% (85 runs sampled)
  62. expand-range x 169,393 ops/sec ±1.76% (80 runs sampled)
  63. minimatch x 15,052 ops/sec ±1.15% (88 runs sampled)
  64. # benchmark/fixtures/range.js (29 bytes)
  65. brace-expansion x 142,968 ops/sec ±1.35% (86 runs sampled)
  66. expand-range x 465,579 ops/sec ±1.43% (86 runs sampled)
  67. minimatch x 126,872 ops/sec ±1.18% (90 runs sampled)
  68. ```
  69. ## Related projects
  70. You might also be interested in these projects:
  71. * [braces](https://www.npmjs.com/package/braces): Fastest brace expansion for node.js, with the most complete support for the Bash 4.3 braces… [more](https://www.npmjs.com/package/braces) | [homepage](https://github.com/jonschlinkert/braces)
  72. * [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or multiplier to… [more](https://www.npmjs.com/package/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range)
  73. * [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch)
  74. ## Contributing
  75. Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/expand-range/issues/new).
  76. ## Building docs
  77. Generate readme and API documentation with [verb](https://github.com/verbose/verb):
  78. ```sh
  79. $ npm install verb && npm run docs
  80. ```
  81. Or, if [verb](https://github.com/verbose/verb) is installed globally:
  82. ```sh
  83. $ verb
  84. ```
  85. ## Running tests
  86. Install dev dependencies:
  87. ```sh
  88. $ npm install -d && npm test
  89. ```
  90. ## Author
  91. **Jon Schlinkert**
  92. * [github/jonschlinkert](https://github.com/jonschlinkert)
  93. * [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
  94. ## License
  95. Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
  96. Released under the [MIT license](https://github.com/jonschlinkert/expand-range/blob/master/LICENSE).
  97. ***
  98. _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on May 05, 2016._