mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
WIP
This commit is contained in:
@@ -276,6 +276,11 @@ export const eval_modules = (
|
||||
const codestring =
|
||||
`
|
||||
let children, prev_children
|
||||
|
||||
// TODO refactor, move patch_promise here
|
||||
globalThis.get_children = () => children
|
||||
globalThis.set_children = (_children) => children = _children
|
||||
|
||||
// TODO use native array for stack for perf?
|
||||
const stack = new Array()
|
||||
|
||||
|
||||
@@ -5,11 +5,36 @@ export const patch_promise = window => {
|
||||
return
|
||||
}
|
||||
|
||||
class PromiseRecordChildren extends Promise {
|
||||
then(on_resolve, on_reject) {
|
||||
let children = window.get_children()
|
||||
if(children == null) {
|
||||
children = []
|
||||
window.set_children(children)
|
||||
}
|
||||
return super.then(
|
||||
on_resolve == null
|
||||
? null
|
||||
: value => {
|
||||
window.set_children(children)
|
||||
return on_resolve(value)
|
||||
},
|
||||
|
||||
on_reject == null
|
||||
? null
|
||||
: error => {
|
||||
window.set_children(children)
|
||||
return on_reject(error)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
class PromiseWithStatus extends window.Promise {
|
||||
constructor(fn) {
|
||||
let status
|
||||
let is_constructor_finished = false
|
||||
const p = new window.Promise.Original(
|
||||
const p = new PromiseRecordChildren(
|
||||
(resolve, reject) => {
|
||||
fn(
|
||||
(value) => {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
export const reserved = [
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
// TODO: fix parser to allow catch be an Object key, as other reserved words.
|
||||
// Currently we make exception for promise.catch
|
||||
// 'catch',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
@@ -14,7 +16,9 @@ export const reserved = [
|
||||
'else',
|
||||
'export',
|
||||
'extends',
|
||||
'finally',
|
||||
// TODO: fix parser to allow finally be an Object key, as other reserved words.
|
||||
// Currently we make exception for promise.finally
|
||||
// 'finally',
|
||||
'for',
|
||||
'function',
|
||||
'if',
|
||||
|
||||
Reference in New Issue
Block a user