From 7c369225646c8c7491d97e2123de2e89f7ec0967 Mon Sep 17 00:00:00 2001 From: anseki Date: Sat, 23 May 2015 14:19:21 +0900 Subject: [PATCH] Fix: `keyInSelect` does not check empty `items`. --- lib/readline-sync.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/readline-sync.js b/lib/readline-sync.js index 3d3a1b6..e10db32 100644 --- a/lib/readline-sync.js +++ b/lib/readline-sync.js @@ -1190,7 +1190,7 @@ exports.keyInSelect = function(items, query, options) { }), // added: guide, cancel keylist = '', key2i = {}, charCode = 49 /* '1' */, display = '\n'; - if (!Array.isArray(items) || items.length > 35) + if (!Array.isArray(items) || !items.length || items.length > 35) { throw '`items` must be Array (max length: 35).'; } items.forEach(function(item, i) { diff --git a/package.json b/package.json index 8451025..7d2414d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "readline-sync", - "version": "1.2.15", + "version": "1.2.16", "title": "readlineSync", "description": "Synchronous Readline for interactively running to have a conversation with the user via a console(TTY).", "keywords": [