diff --git a/README.md b/README.md index 00f1664..cb604ce 100644 --- a/README.md +++ b/README.md @@ -13,19 +13,24 @@ npm i fill-range --save ```js var range = require('fill-range'); -range('a', 'e') +range('a', 'e'); //=> ['a', 'b', 'c', 'd', 'e'] ``` **Params** ```js -range(start, stop, increment); +range(start, stop, step, options, fn); ``` - - `start`: the number or letter to start with - - `end`: the number or letter to end with - - `step`: optionally pass the increment to use. works for letters or numbers + - `start`: **{String|Number}** the number or letter to start with + - `end`: **{String|Number}** the number or letter to end with + - `step`: **{String|Number}** optionally pass the step to use. works for letters or numbers. + - `options`: **{Object}**: + + `makeRe`: return a regex-compatible string (still returned as an array for consistency) + + `step`: pass the step on the options as an alternative to passing it as an argument + + `silent`: `true` by default, set to false to throw errors for invalid ranges. + - `fn`: **{Function}** optionally [pass a function](#custom-function) to modify each character **Examples** @@ -59,6 +64,24 @@ range('A', 'E', 2) //=> ['A', 'C', 'E'] ``` +### Invalid ranges + +When an invalid range is passed, `null` is returned. + +```js +range('1.1', '2'); +//=> null + +range('a', '2'); +//=> null + +range(1, 10, 'foo'); +//=> null +``` + +If you want errors to be throw, pass `silent: false` on the options: + + ### Custom function Optionally pass a custom function as the third or fourth argument: @@ -235,10 +258,10 @@ Released under the MIT license *** -_This file was generated by [verb](https://github.com/assemble/verb) on January 26, 2015._ +_This file was generated by [verb](https://github.com/assemble/verb) on January 30, 2015._ [randomatic]: https://github.com/jonschlinkert/randomatic [expand-range]: https://github.com/jonschlinkert/expand-range [micromatch]: https://github.com/jonschlinkert/micromatch -[braces]: https://github.com/jonschlinkert/braces \ No newline at end of file +[braces]: https://github.com/jonschlinkert/braces