From 291803c31f829fe0d32bb3207bc11def95a7408c Mon Sep 17 00:00:00 2001 From: Nevena Bojovic Date: Tue, 1 Mar 2022 20:05:50 +0100 Subject: Urađena test aplikacija. Povezan front i back. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node_modules/inquirer/lib/utils/events.js | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/events.js (limited to 'sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/events.js') diff --git a/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/events.js b/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/events.js new file mode 100644 index 00000000..b4b16bb1 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/inquirer/lib/utils/events.js @@ -0,0 +1,54 @@ +'use strict'; +const { fromEvent } = require('rxjs'); +const { filter, map, share, takeUntil } = require('rxjs/operators'); + +function normalizeKeypressEvents(value, key) { + return { value, key: key || {} }; +} + +module.exports = function (rl) { + const keypress = fromEvent(rl.input, 'keypress', normalizeKeypressEvents) + .pipe(takeUntil(fromEvent(rl, 'close'))) + // Ignore `enter` key. On the readline, we only care about the `line` event. + .pipe(filter(({ key }) => key.name !== 'enter' && key.name !== 'return')); + + return { + line: fromEvent(rl, 'line'), + keypress, + + normalizedUpKey: keypress.pipe( + filter( + ({ key }) => + key.name === 'up' || key.name === 'k' || (key.name === 'p' && key.ctrl) + ), + share() + ), + + normalizedDownKey: keypress.pipe( + filter( + ({ key }) => + key.name === 'down' || key.name === 'j' || (key.name === 'n' && key.ctrl) + ), + share() + ), + + numberKey: keypress.pipe( + filter((e) => e.value && '123456789'.indexOf(e.value) >= 0), + map((e) => Number(e.value)), + share() + ), + + spaceKey: keypress.pipe( + filter(({ key }) => key && key.name === 'space'), + share() + ), + aKey: keypress.pipe( + filter(({ key }) => key && key.name === 'a'), + share() + ), + iKey: keypress.pipe( + filter(({ key }) => key && key.name === 'i'), + share() + ), + }; +}; -- cgit v1.2.3