Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3d94029

Browse files
authoredJun 30, 2024··
Fix callback invocation for readline.question (#38)
* call mkEffectFn1 on cb to question * typo * update changelog
1 parent 0e5f4a8 commit 3d94029

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed
 

‎CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Breaking changes:
99
New features:
1010

1111
Bugfixes:
12+
- Ensure that callbacks passed to `question` and `question'` are invoked
13+
- Fixed typo in options passed to `readline.createInterface`
1214

1315
Other improvements:
1416

‎src/Node/ReadLine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const createInterfaceImpl = (options) => readline.createInterface({
1414
historySize: options.historySize,
1515
removeHistoryDuplicates: options.removeHistoryDuplicates,
1616
prompt: options.prompt,
17-
crlDelay: options.crlDelay,
17+
crlfDelay: options.crlfDelay,
1818
escapeCodeTimeout: options.escapeCodeTimeout,
1919
tabSize: options.tabSize,
2020
signal: options.signal

‎src/Node/ReadLine.purs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ foreign import promptOptsImpl :: EffectFn2 (Boolean) (Interface) (Unit)
316316
-- |
317317
-- | The callback function passed to `rl.question()` does not follow the typical pattern of accepting an Error object or null as the first argument. The callback is called with the provided answer as the only argument.
318318
question :: String -> (String -> Effect Unit) -> Interface -> Effect Unit
319-
question text cb iface = runEffectFn3 questionImpl iface text cb
319+
question text cb iface = runEffectFn3 questionImpl iface text $ mkEffectFn1 cb
320320

321-
foreign import questionImpl :: EffectFn3 (Interface) (String) ((String -> Effect Unit)) Unit
321+
foreign import questionImpl :: EffectFn3 (Interface) (String) (EffectFn1 String Unit) Unit
322322

323323
-- | Writes a query to the output, waits
324324
-- | for user input to be provided on input, then invokes
@@ -338,9 +338,9 @@ foreign import questionImpl :: EffectFn3 (Interface) (String) ((String -> Effect
338338
-- |
339339
-- | The callback function passed to `rl.question()` does not follow the typical pattern of accepting an Error object or null as the first argument. The callback is called with the provided answer as the only argument.
340340
question' :: String -> { signal :: AbortSignal } -> (String -> Effect Unit) -> Interface -> Effect Unit
341-
question' text opts cb iface = runEffectFn4 questionOptsCbImpl iface text opts cb
341+
question' text opts cb iface = runEffectFn4 questionOptsCbImpl iface text opts $ mkEffectFn1 cb
342342

343-
foreign import questionOptsCbImpl :: EffectFn4 (Interface) (String) { signal :: AbortSignal } ((String -> Effect Unit)) Unit
343+
foreign import questionOptsCbImpl :: EffectFn4 (Interface) (String) { signal :: AbortSignal } (EffectFn1 String Unit) Unit
344344

345345
-- | The rl.resume() method resumes the input stream if it has been paused.
346346
resume :: Interface -> Effect Unit

0 commit comments

Comments
 (0)
Please sign in to comment.