MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

dont blow up when trying to fetch commonjs defaults

+33 -3
+1
include/ant.h
··· 160 160 void js_process_promise_handlers(ant_t *js, ant_value_t promise); 161 161 void js_mark_promise_trigger_dequeued(ant_t *js, ant_value_t promise); 162 162 bool js_mark_promise_trigger_queued(ant_t *js, ant_value_t promise); 163 + bool js_try_get_own_data_prop(ant_t *js, ant_value_t obj, const char *key, size_t key_len, ant_value_t *out); 163 164 void js_reject_promise(ant_t *js, ant_value_t promise, ant_value_t value); 164 165 void js_resolve_promise(ant_t *js, ant_value_t promise, ant_value_t value); 165 166
+29
src/ant.c
··· 3132 3132 return lookup_prop_meta(js, cur_obj, PROP_META_STRING, key, klen, 0, out); 3133 3133 } 3134 3134 3135 + bool js_try_get_own_data_prop(ant_t *js, ant_value_t obj, const char *key, size_t key_len, ant_value_t *out) { 3136 + if (out) *out = js_mkundef(); 3137 + if (!key || !out) return false; 3138 + 3139 + uint8_t t = vtype(obj); 3140 + if (t == T_FUNC) obj = js_func_obj(obj); 3141 + else if (t != T_OBJ && t != T_ARR) return false; 3142 + 3143 + ant_value_t as_obj = js_as_obj(obj); 3144 + if (is_proxy(as_obj)) return false; 3145 + 3146 + prop_meta_t meta; 3147 + bool has_meta = lookup_string_prop_meta(js, as_obj, key, key_len, &meta); 3148 + if (has_meta && (meta.has_getter || meta.has_setter)) return false; 3149 + 3150 + ant_offset_t off = lkp(js, as_obj, key, (ant_offset_t)key_len); 3151 + if (off != 0) { 3152 + *out = propref_load(js, off); 3153 + return true; 3154 + } 3155 + 3156 + if (array_obj_ptr(as_obj) && is_length_key(key, (ant_offset_t)key_len)) { 3157 + *out = tov((double)get_array_length(js, as_obj)); 3158 + return true; 3159 + } 3160 + 3161 + return false; 3162 + } 3163 + 3135 3164 ant_value_t js_setprop(ant_t *js, ant_value_t obj, ant_value_t k, ant_value_t v) { 3136 3165 uint8_t ot = vtype(obj); 3137 3166
+3 -3
src/esm/commonjs.c
··· 83 83 84 84 while (js_prop_iter_next(&iter, &key, &key_len, NULL)) { 85 85 if (key_len == 7 && memcmp(key, "default", 7) == 0) continue; 86 - 87 - ant_value_t value = js_get(js, exports_val, key); 88 - if (is_err(value)) { js_prop_iter_end(&iter); return value; } 86 + 87 + ant_value_t value = js_mkundef(); 88 + if (!js_try_get_own_data_prop(js, exports_val, key, key_len, &value)) continue; 89 89 90 90 ant_value_t res = setprop_cstr(js, ns, key, key_len, value); 91 91 if (is_err(res)) { js_prop_iter_end(&iter); return res; }