mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
refactor
This commit is contained in:
11
src/eval.js
11
src/eval.js
@@ -14,9 +14,6 @@ import {
|
|||||||
|
|
||||||
import {has_toplevel_await} from './find_definitions.js'
|
import {has_toplevel_await} from './find_definitions.js'
|
||||||
|
|
||||||
// external
|
|
||||||
import {patch_promise} from './patch_promise.js'
|
|
||||||
|
|
||||||
// TODO: fix error messages. For example, "__fn is not a function"
|
// TODO: fix error messages. For example, "__fn is not a function"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -399,12 +396,7 @@ export const eval_modules = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
const set_promise_status = value => {
|
const set_promise_status = value => {
|
||||||
// TODO refactor, put is_status_requested inside status
|
|
||||||
if(value instanceof Promise) {
|
if(value instanceof Promise) {
|
||||||
if(value.is_status_requested) {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
value.is_status_requested = true
|
|
||||||
// record stack for async calls, so expand calls works sync
|
// record stack for async calls, so expand calls works sync
|
||||||
set_record_call()
|
set_record_call()
|
||||||
// TODO why we set status for wrapped value and not for wrapper?
|
// TODO why we set status for wrapped value and not for wrapper?
|
||||||
@@ -431,8 +423,7 @@ export const eval_modules = (
|
|||||||
children = []
|
children = []
|
||||||
}
|
}
|
||||||
const children_copy = children
|
const children_copy = children
|
||||||
if(value instanceof Promise && !value.is_status_requested) {
|
if(value instanceof Promise) {
|
||||||
value.is_status_requested = true
|
|
||||||
value.then(
|
value.then(
|
||||||
v => {
|
v => {
|
||||||
value.status = {ok: true, value: v}
|
value.status = {ok: true, value: v}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const adjust_path = path => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
const load_external_modules = async state => {
|
const load_external_modules = async state => {
|
||||||
const urls = state.loading_external_imports_state.external_imports
|
const urls = state.loading_external_imports_state.external_imports
|
||||||
const results = await Promise.all(
|
const results = await Promise.all(
|
||||||
@@ -62,6 +63,7 @@ const load_external_modules = async state => {
|
|||||||
))
|
))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
const dir = load_dir('.')
|
const dir = load_dir('.')
|
||||||
|
|
||||||
@@ -71,10 +73,14 @@ const i = test_initial_state(
|
|||||||
{}, // files
|
{}, // files
|
||||||
{project_dir: dir, entrypoint: 'test/run.js'}
|
{project_dir: dir, entrypoint: 'test/run.js'}
|
||||||
)
|
)
|
||||||
assert_equal(i.loading_external_imports_state != null, true)
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
assert_equal(i.loading_external_imports_state != null, true)
|
||||||
const external_imports = await load_external_modules(i)
|
const external_imports = await load_external_modules(i)
|
||||||
const loaded = COMMANDS.external_imports_loaded(i, i, external_imports)
|
const loaded = COMMANDS.external_imports_loaded(i, i, external_imports)
|
||||||
|
*/
|
||||||
|
|
||||||
|
const loaded = i
|
||||||
|
|
||||||
assert_equal(loaded.eval_modules_state != null, true)
|
assert_equal(loaded.eval_modules_state != null, true)
|
||||||
const s = loaded.eval_modules_state
|
const s = loaded.eval_modules_state
|
||||||
|
|||||||
Reference in New Issue
Block a user