Edoardo Luppi
10/04/2023, 5:11 PMpublic fun Status.isSuccessful(): Boolean {
return code == HttpStatuses.Ok
|| code == HttpStatuses.Created
|| code == HttpStatuses.Accepted
|| code == HttpStatuses.NoContent
|| code == HttpStatuses.ResetContent
|| code == HttpStatuses.PartialContent
}
And I didn't expect the compiled JS to be this convoluted 👀
function isSuccessful(_this__u8e3s4) {
var tmp;
var tmp_0;
var tmp_1;
var tmp_2;
var tmp_3;
if (_this__u8e3s4.h19_1 === 200) {
tmp_3 = true;
} else {
tmp_3 = _this__u8e3s4.h19_1 === 201;
}
if (tmp_3) {
tmp_2 = true;
} else {
tmp_2 = _this__u8e3s4.h19_1 === 202;
}
if (tmp_2) {
tmp_1 = true;
} else {
tmp_1 = _this__u8e3s4.h19_1 === 204;
}
if (tmp_1) {
tmp_0 = true;
} else {
tmp_0 = _this__u8e3s4.h19_1 === 205;
}
if (tmp_0) {
tmp = true;
} else {
tmp = _this__u8e3s4.h19_1 === 206;
}
return tmp;
}
Is this output by design?jw
10/04/2023, 5:21 PMEdoardo Luppi
10/04/2023, 5:28 PMjw
10/04/2023, 5:31 PMEdoardo Luppi
10/04/2023, 5:34 PMit has to generate code which satisfies the entire expressionDo you think it's worth opening an issue for a possible optimization? Or should I just forget about it.
jw
10/04/2023, 5:44 PMh;console.log(!(200!==(h=200).h19_1&&201!==h.h19_1&&202!==h.h19_1&&204!==h.h19_1&&205!==h.h19_1)||206===h.h19_1)
for that code + console.log(isSuccessful(200))
Edoardo Luppi
10/04/2023, 5:46 PMjw
10/04/2023, 5:46 PMEdoardo Luppi
10/04/2023, 5:47 PMEdoardo Luppi
10/04/2023, 5:50 PMEdoardo Luppi
10/04/2023, 6:00 PMArtem Kobzar
10/06/2023, 2:25 PMEdoardo Luppi
10/06/2023, 2:43 PMEdoardo Luppi
10/06/2023, 2:46 PMArtem Kobzar
10/06/2023, 2:53 PMEdoardo Luppi
10/06/2023, 3:33 PMArtem Kobzar
10/06/2023, 4:34 PMArtem Kobzar
10/06/2023, 4:36 PMEdoardo Luppi
10/06/2023, 4:39 PMhfhbd
10/09/2023, 8:00 AMEdoardo Luppi
10/09/2023, 8:02 AMbrowser
target. I suppose with nodeJs
you'd have to integrate an additional step and use external tools after the build is donehfhbd
10/09/2023, 8:14 AMmodule.exports
again. Don't know yet if there is a web pack option to remove this module option (again).Edoardo Luppi
10/09/2023, 8:48 AMbinaries.executable()
Edoardo Luppi
10/09/2023, 8:49 AMEdoardo Luppi
10/09/2023, 8:55 AMhfhbd
10/09/2023, 9:01 AMimplementation
.Edoardo Luppi
10/09/2023, 9:02 AMbut you could minify your library to distribute a smaller binaryDefinitely. I've asked on the linked issue why libraries aren't covered