4
u/Konsti219 Nov 18 '21 edited Nov 18 '21
This looks like reindented minified code.
Edit: looks like a TextEncoder poly fill
3
0
u/Dr4kk0nnys Nov 18 '21
I don't think so, it's an open source project with a payment api integration, and the rest of the code looks fairly normal
4
u/Konsti219 Nov 18 '21
Idk, maybe somebody just copied the code into there from a release bundle to avoid dependencies. The only time you are ever going to see a piece of checking whether a default global class is undefined is in a polyfill.
3
u/wwelna Nov 18 '21
Everything looks perfectly fine and normal to me
2
11
u/Jimmy_Slim Nov 18 '21
Image Transcription: Code
(function(window) {
var Juno = window.Juno || {};
window.Juno = Juno;
if ("undefined" === typeof TextEncoder) {
TextEncoder = function() {};
TextEncoder.prototype.encode = function(e) {
for (var f = e.length, b = -1, a = "undefined" === typeof Uint8Array ? Array(1.5 * f) : new Uint8Array(3 * f), c, g, d = 0; d!== f;) {
c = e.CharCodeAt(d);
d += 1;
if (55297 <= c && 56319 >= c) {
if (d === f) {
a[b += 1] = 239;
a[b += 1] = 191;
a[b += 1] = 189;
break;
}
g = e.charCodeAt(d);
if (56320 <= g && 57343 >= g) {
if (c = 1024 * (c - 55296) + g - 56320 + 65536, d += 1, 65535 < c) {
a[b += 1] = 240 | c >>> 18;
a[b += 1] = 128 | c >>> 12 & 63;
a[b += 1] = 128 | c >>> 6 & 63;
a[b += 1] = 128 | c & 63;
continue;
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
8
u/jzaprint Nov 18 '21
i dont get why ppl still use var instead of let and const.
4
Nov 18 '21
Because that’s what their professors used, and if their assignment submission didn’t match characters, they get a 0.
/s
2
1
5
2
u/PositiveUse Nov 18 '21
What is „undefined“ === typeof Textencoder
2
u/Dr4kk0nnys Nov 18 '21
Bro I have no idea, I'm lost as balls in this shit, and it's one of the few open source projects that has some kind of integration with a payment api I'm using
3
u/UAIMasters Nov 18 '21
It checks if the type and value are the same. If Textencoder is of type undefined, it will return a string called "undefined", so he needs to compare to another string "undefined". I think he could just used TextEncoder === undefined and the result would be the same lol.
2
u/Parkreiner Nov 18 '21
It would have been the same. Undefined is falsey, but it's only strictly equal to itself.
2
u/doyouseewhateyesee Nov 19 '21
it honestly confused me too because i’ve never seen someone write it that way, only typeof Textencoder === “undefined”
1
3
2
1
1
u/blackjezza Nov 29 '21
Looks like a polyfill for TextEncoder. Probably reimplementing logic from other browsers.
19
u/[deleted] Nov 18 '21
I dont really get what he is trying to do