function incrementListIndex(current, dir, opt) { var len = opt.choices.realLength; var shouldLoop = 'loop' in opt ? Boolean(opt.loop) : true; if (dir === 'up') { if (current > 0) { return current - 1; } return shouldLoop ? len - 1 : current; } if (dir === 'down') { if (current < len - 1) { return current + 1; } return shouldLoop ? 0 : current; } throw new Error('dir must be up or down'); } module.exports = incrementListIndex;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
events.js | File | 1.4 KB | 0644 |
|
incrementListIndex.js | File | 481 B | 0644 |
|
paginator.js | File | 2.09 KB | 0644 |
|
readline.js | File | 1.16 KB | 0644 |
|
screen-manager.js | File | 3.83 KB | 0644 |
|
utils.js | File | 813 B | 0644 |
|