Giter VIP home page Giter VIP logo

repl's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

repl's Issues

Keys don't work (or as expected)

  • Delete key should not be a backspace
  • Ctrl-W (could either use readline(3) semantics, where it deletes until it hits a white space, or existing Node.js REPL semantics where it deletes until it hits a word boundary; personally prefer readline(3) semantics)

Standard autocomplete behavior

I am a little surprised that autocomplete works differently from any other major implementation like Bash, ZSH etc.
The only way to use a suggested completion is press "right" key which is located to the side of the keyboard and requires a very inconvenient hand move.

Don't you want to really complete the expression when there is only one variant or otherwise list variants like in Bash?

Inspector-less Node.js build

Should we make it clear that this is not designed to work on Node.js builds with inspector disabled? Or should we try to make it work? (I fear that a REPL that doesn't work with some Node.js configurations may be difficult to be accepted to core.)

Unexpected token {

Attempting to run

C:\Users\username>node-prototype-repl

On Windows 10 with Node.js v8.12.0, the latest Node.js LTS version (as of writing), results in this fatal error:

C:\Users\username\AppData\Roaming\npm\node_modules\@nodejs\repl\src\repl.js:227
          } catch {} // eslint-disable-line no-empty
                  ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Users\username\AppData\Roaming\npm\node_modules\@nodejs\repl\src\index.js:7:14)

How to change the color of completions in the terminal?

I am sorry if this is the wrong place to ask, but I couldn't find a relevant mailing list / forum.
[Attempts to get an answer on Discord and Reddit failed.]

I am using using Node in terminal with the Solarized Dark theme.
Invoking Node with node, that is, I am using the standard repl fromlib/repl.js
I am quite happy with the colors, except the colors for completions
(the last, black line in the image show such a completion)
and the colors for stack traces. The black color used for completions and
traces are difficult to read on the dark background.

Now since I am not the only one using a dark theme in the terminal,
I thought, I could easily lookup how to change the colors.

According to the manual for lib/repl.js something called "styles" are supported,
but I can't figure out which style is used for completions.

The standard color my terminal is gray, so somewhere in the code for lib/repl.js
there must be a color change to black.

Have I overlooked a simple solution?

If not, can you point me to the relevant section of code in lib/repl.js?

image

tests

all the things need to be tested.

Multi-line input not possible

Hi guys, I often use the node REPL to analyse objects/arrays I've logged. In the mainline REPL, I just paste em in and it seems to detect when a line isn't complete:
image

With the prototype REPL, it automatically executes each line:
image

Which is a bit of a hassle when you've got big arrays of objects:
image
etc

Make README more clear

Could you explain how to point NODE_REPL_EXTERNAL_MODULE to which node-prototype-repl ?

Ctrl-left/right should jump by word

In the existing node REPL (which uses readline, I think), pressing the left/right arrow keys while holding down control jumps the cursor to the end or beginning of a word, or to the next or previous word. (Take that sentence with a grain of salt; I don't know exactly how it works, but it's still a feature I make frequent use of.) See the following diagram for an example; each | is a stop where the cursor moves to when you press ctrl-left/right:

console.log("Hello, world!")
|      ||  | |    | |    |  |

The same stops are used when pressing left or right.

By the looks of it, the stops are placed at the first character of every word (which are alphanumeric, I think) and the first character of a chunk of symbols (e.g. ., (", , , !)").

Add support for await

This is a feature request to implement a similar existing feature In the chrome console on NodeJs REPL.

> asyncTaskThatResolvesNumber();
Promise<pending>

// chrome console
> await asyncTaskThatResolvesNumber();
123

// nodejs repl
> await asyncTaskThatResolvesNumber();
await asyncTaskThatResolvesNumber()
^^^^^

Uncaught:
SyntaxError: await is only valid in async functions and the top level bodies of modules

I think this can be very helpful for debugging or just quick trying out stuff. Current workaround I use is

> asyncTaskThatResolvesNumber().then(console.log)

Didn't work ?

After entering the repl, it was exited whatever I stdin.
How should I use it ?
screen shot 2018-09-24 at 9 54 23 pm

Save to REPL history before running input

I'm currently working with big files and try to manipulate them with a few JS lines here and there and sometimes the REPL crashes because it's running out of memory - which is fine, that's just the way it is.

But what I noticed here is that it's not saving the executed line to the history unless it's still alive after (so I pretty much lose the line that caused the termination).

I would like to propose a change so that it first appends to history (and saves the file?) and then executes the input.

Status of this project?

๐Ÿ‘‹ Hi @devsnek. I'm curious what the status of this project is โ€“ I've been poking around improving the existing node REPL a bit, and came across this repo. Is there a plan to eventually move it into mainline node? If yes, do you have an idea of the features that are missing/work that remains to be done in your opinion before heading in that direction? And, how much latitude do you feel there is to break the existing REPLServer interface?

Issues with Number.MIN_VALUE

Expected behavior

Directly evaluating Number.MIN_VALUE should return the value 5e-324.
Operating on Number.MIN_VALUE should return the correct result.

Actual behavior

Directly evaluating Number.MIN_VALUE instantly kills / exits the REPL process. No stacktrace or output is printed. This only occurs when evaluated directly, ie. console.log(Number.MIN_VALUE) prints correctly without exiting.

The automatic evaluation that prints as a comment on the same line before pressing enter still displays correctly (> Number.MIN_VALUE // 5e-324).

Performing addition, subtraction, and division operations on Number.MIN_VALUE returns incorrect results. Performing multiplication on Number.MIN_VALUE causes the REPL process to exit as well.

Concatenating a string with Number.MIN_VALUE does return the correct result without exiting.

This behavior only occurs with Number.MIN_VALUE, evaluating and operating on Number.MAX_VALUE returns correctly.

Steps to reproduce

Exit on evaluation:

$ node-prototype-repl
Node.js v12.8.1 (V8 7.5.288.22-node.16)
Prototype REPL - https://github.com/nodejs/repl
> Number.MIN_VALUE // 5e-324

$

Incorrect arithmetic results and exiting on multiplication:

$ node-prototype-repl
Node.js v12.8.1 (V8 7.5.288.22-node.16)
Prototype REPL - https://github.com/nodejs/repl
> Number.MIN_VALUE + 100 // 100
100
> Number.MIN_VALUE - 100 // -100
-100
> Number.MIN_VALUE / 100 // 0
0
> Number.MIN_VALUE * 100 // 4.94e-322

$

Correct evaluation when concatenating with a string:

$ node-prototype-repl
Node.js v12.8.1 (V8 7.5.288.22-node.16)
Prototype REPL - https://github.com/nodejs/repl
> Number.MIN_VALUE + 'Test' // '5e-324Test'
'5e-324Test'

[feature request] Allow multiline up arrow (like Chrome Devtools)

Currently node's repl is pretty painful when dealing with multiline expressions/statements like:

Point = class {
  x; y;
  constructor(x, y) {
    this.x = x;
    this.yy = y;
  }
}

After entering such an expression often you'll notice is has an error somewhere, however to fix the error it'll generally involve going back to each line in order and entering it again e.g.:

https://1drv.ms/v/s!AqOK_5mhCFkag7VLMCfWVeCX_IFTtA?e=I6ikhd

Now chrome devtools/ndb has a nice feature in that a single up arrow goes to the last set of statements evaluated and be navigated entirely using a keyboard using Enter and Shift-Enter to navigate e.g.:

https://1drv.ms/v/s!AqOK_5mhCFkag7VMdWd_CJqhe_X9Ig?e=Gm86DL

I'd like to propose doing the same with Node's REPL.

It's a lot easier to work with as you don't need to do a bunch of up-arrows to re-enter every single line of the previous expression in order to fix it. The current behavior is also pretty error prone, especially for functions where you might accidentally re-order statements creating new errors and hence having to redo them all over again.

repl Ctrl-r keybinding to search history

Most repl's I've used before allow you to quickly get a previous command back by using the Ctrl+r key to search the command history. It makes life so much easier when you're testing stuff out. Any chance this could be implemented for the nodejs repl?

Prompt refresh is visible and causes annoying flicker

Version: Node.js 17.6.0 (V8 9.6.180.15-node.13)
on iTerm2, Build 3.4.16.
System: Darwin MacPro.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T8101 arm64

It's exactly the same issue as the one described here. https://jira.mongodb.org/browse/MONGOSH-730

Quoted the problem description:

When I type at the prompt I can see the cursor going to the beginning of the line and come back, causing a very annoying and distracting flicker. I'm using mongosh 0.12.0, MacOS Catalina and iTerm2 3.4.5

I can still reproduce the same problem while using iTerm2 shell with node-prototype-repl. Any ideas to fix this issue?

how to get started?

  • does not install, Missing package version
  • should there be a bin: key in the package.json so that a shell command can be exported?

Rename primary branch to main

We are going through all of the node.js repositories to rename the primary branch to main. Please see nodejs/node#33864 for more context.

I don't see any references to the master branch so I don't think the rename will cause any issues.

Please let me know if you have any concerns by June 26th, otherwise I'll go ahead with the rename.

Node v8 support

Any plans for supporting older versions of Node? Looks like Node 8 is failing because of generator syntax usage.

Thanks!

Error stacktrace is not getting printed properly

Hello,

I guess with this commit : e06c75c

Error stacktrace is missing outside repl context too. For example, when I was working on this PR : #17

I noticed when assertions failed, the stack trace was missing. I saw only the below:

assert.js:269
    throw err;
    ^

AssertionError [ERR_ASSERTION]: should throw syntax error
    at 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.