这是indexloc提供的服务,不要输入任何密码
Skip to content

Difference in execution of for await between repl & script #538

@KaruroChori

Description

@KaruroChori

This code (directly taken from the docs):

const dirIter = await tjs.readdir('.');
for await (const item of dirIter) {
    console.log(item.name);
}

If run as a script will work just fine.
If run in the repl tjs is not happy of the for await:

SyntaxError: Unexpected identifier 'await'
    at <evalScript>:1:1
    at evalScript (native)
    at doEval (:0:0)
    at eval_and_print (:0:0)
    at handle_cmd (:0:0)
    at readline_handle_cmd (:0:0)
    at handle_key (:0:0)
    at handle_char (:0:0)
    at handle_byte (:0:0)
    at term_read_handler (:0:0)

> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions