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.

remove heavy mkfun and replace with this binding

+10 -11
+10 -11
src/modules/fetch.c
··· 60 60 } 61 61 } 62 62 63 - static jsval_t response_text(struct js *js, jsval_t *args, int nargs) { 64 - (void)args; (void)nargs; 63 + static jsval_t response_text(struct js *js, jsval_t *args, int nargs) { 64 + jsval_t this = js_getthis(js); 65 + jsval_t body = js_get_slot(js, this, SLOT_DATA); 65 66 66 - jsval_t fn = js_getcurrentfunc(js); 67 - jsval_t body = js_get_slot(js, fn, SLOT_DATA); 68 67 jsval_t promise = js_mkpromise(js); 69 68 js_resolve_promise(js, promise, body); 70 69 71 70 return promise; 72 71 } 73 72 74 - static jsval_t response_json(struct js *js, jsval_t *args, int nargs) { 75 - (void)args; (void)nargs; 76 - 77 - jsval_t fn = js_getcurrentfunc(js); 78 - jsval_t body = js_get_slot(js, fn, SLOT_DATA); 73 + static jsval_t response_json(struct js *js, jsval_t *args, int nargs) { 74 + jsval_t this = js_getthis(js); 75 + jsval_t body = js_get_slot(js, this, SLOT_DATA); 79 76 jsval_t parsed = js_json_parse(js, &body, 1); 80 77 jsval_t promise = js_mkpromise(js); 81 78 ··· 93 90 js_set(js, response_obj, "ok", status >= 200 && status < 300 ? js_mktrue() : js_mkfalse()); 94 91 js_set(js, response_obj, "status", js_mknum(status)); 95 92 96 - js_set(js, response_obj, "text", js_heavy_mkfun(js, response_text, body_str)); 97 - js_set(js, response_obj, "json", js_heavy_mkfun(js, response_json, body_str)); 93 + js_set_slot(js, response_obj, SLOT_DATA, body_str); 94 + 95 + js_set(js, response_obj, "text", js_mkfun(response_text)); 96 + js_set(js, response_obj, "json", js_mkfun(response_json)); 98 97 99 98 return response_obj; 100 99 }