fix(#56): delete range of tasks#58
Conversation
|
|
||
| _generateNumbers(value) { | ||
| let _start = value[0] || null; | ||
| let _end = value[1] || null; |
There was a problem hiding this comment.
Should this still work if the user inputs taskbook -d 1-5-10?
Looks like it will currently just include 1-5, but maybe an error should be returned, or 1-10 should be used instead?
There was a problem hiding this comment.
You should use 1-10 instead of taskbook -d 1-5-10. That's more logical
| [_start, _end] = [_end, _start]; | ||
| } | ||
|
|
||
| for (let i = parseInt(_start, 10); i <= parseInt(_end, 10); i++) { |
There was a problem hiding this comment.
You use parseInt on both start and end twice, why not assign this one time and reuse?
| } | ||
|
|
||
| _produceNumbers(values) { | ||
| return [...new Set(this._flattenDown(values.map(value => value.indexOf('-') > -1 ? this._generateNumbers(value.split('-')) : value), []))]; |
There was a problem hiding this comment.
I personally think that this line looks more complex than it really should be in the first look.
Why not improve this function to actually iterate in the values and generate a new array directly?
This way you will not need to flatten the array afterwards.
| return result; | ||
| } | ||
|
|
||
| _generateNumbers(value) { |
There was a problem hiding this comment.
Maybe rename to _generateNumbersFromInterval
| _generateNumbers(value) { | |
| _generateNumbersFromInterval(value) { |
This PR solved #56.
Delete a range of tasks
For Example:
tb -d 1-5ortb -d 1-5 7 9-11