runtime + codegen-js: Promise helpers and object/array utilities
Add to el_runtime.js:
promise_then(p, cb) -- p.then(cb), works with any Promise-returning API
promise_catch(p, cb) -- p.catch(cb)
promise_resolve(val) -- Promise.resolve(val)
promise_reject(msg) -- Promise.reject(new Error(msg))
object_assign(t, s) -- Object.assign({}, t, s) (non-mutating)
object_keys(obj) -- Object.keys(obj)
object_values(obj) -- Object.values(obj)
json_deep_clone(obj) -- JSON.parse(JSON.stringify(obj))
array_from(iterable) -- Array.from(iterable)
type_of(val) -- typeof val
instanceof_check(v, n) -- val instanceof globalThis[name]
All new functions added to __el export object and ES named exports.
codegen-js preamble destructure updated to include all new names.
This commit is contained in:
@@ -1105,6 +1105,9 @@ fn codegen_js_inner(stmts: [Map<String, Any>], source: String, bundle_mode: Bool
|
||||
js_emit_line(" window_location, window_redirect, window_on_load,")
|
||||
js_emit_line(" console_log,")
|
||||
js_emit_line(" window_set, window_get, native_js, native_js_call,")
|
||||
js_emit_line(" promise_then, promise_catch, promise_resolve, promise_reject,")
|
||||
js_emit_line(" object_assign, object_keys, object_values, json_deep_clone,")
|
||||
js_emit_line(" array_from, type_of, instanceof_check,")
|
||||
js_emit_line("} = globalThis.__el;")
|
||||
js_emit_blank()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user