« first day (3798 days earlier)      last day (1157 days later) » 

4:34 AM
Is it possible to have a function that calls its self in nodesjs that is not in a route?
 
@EmilC. Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
1 hour later…
5:53 AM
Error: advanced-http: "data" option is configured to support only following data types: Object
getting this error while posting data to server
 
 
1 hour later…
7:01 AM
Hi, everyone
Who has been used coreui-free-vue-admin-template?
 
7:57 AM
I blew my mind today by learning about ES6 generators!
 
@VaibhavDwivedi Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
8:30 AM
@VaibhavDwivedi Generators are super cool!
Love 'em.
 
9:22 AM
I want to render a 3D model using data from a sse server. I've got everything working, but now the event.data inside the onmessage is not accessible outside of this function, can I pass event.data outside of onmessage to another function that render the 3D model. Let me know if this is making sense at all
 
@SamiArja Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
9:44 AM
@SamiArja you're probably looking for something like this stackoverflow.com/questions/14220321/…
 
10:00 AM
@DrogoNevets that is why I am mad at some people, adding libraries that involves more information than writing a module you can use.
@Cerbrus how's the Dutch Climate? :D
 
A little meh at the moment
cold and wet
 
we have had weird weather changes past week
 
Snow -> summer day -> it's freezing
like wtf
 
yeah
and that for almost a week
3 weeks ago: snow/temps near zero
2 weeks ago: spring, 15+ degrees (5 days long)
in between: 1 day freezing, 2 days spring, back -V
1 week ago: freezing again, around 4 degrees
this week: "normal" for early march
I had to shelf back my winter clothing
 
Yea, I don't know what to wear any more xD
I just took the motorcycle out for a ride, and now it's shitty again xD
 
10:08 AM
do you still have curfew after ... 18h ?
 
21:00
That's the only curfew we've had
 
kinda too early. I can understand why it is implemented, but start time at 21:00?
be happy with that. My country is a bad example on that: 3 regions, 2 regions have curfew at 22 whereas the other has it at midnight
it led to funny situations
imagine a sport center that is in region 1, it has to close at 22 because of curfew
 
Meh, I think the curfew is a shitty measure... I mean, I understand that there has to be a rule to get ignorants off of the streets, but this also messes waaaaay too much with safe actions
 
yet, you are allowed to have a small talk on the car park until 24pm ... because it is in region 3
(it is a real life example at some locations here)
 
Yea, that's inconsistent...
Should be a country-wide rule
 
10:14 AM
eh, we are used with that
like public health, we have 9 ministers for that
|| shrug
 
¯\_(ツ)_/¯
 
We have a fat minister of health... She could count for 9 of'm
or had
 
lookup Maggie De Block :D
 
Yea, that's who I was thinking of, but she's not ours xD
 
she was our federal minister for public health in prev gov
 
10:16 AM
Politics aren't at all interesting to me
 
It is amusing for me because of the level of backstabbing, hypocrisy, laisez-faire ect
 
I just think politics, or actually politicians are annoying
So out of touch with their people
 
ur annoying
 
oh come'on Ben, at least we are a somewhat family of each other, with those politicians representing your country.
 
I just got access to the chat!!
 
10:29 AM
@Emil Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@KarelG I'm joking
somewhat 😂
 
😉
 
10:56 AM
Who has been used coreui-free-vue-admin-template?
 
probably a bunch of people
 
11:29 AM
probably same people as those that imports leftpad or isOdd npm package :D
I recall I have done consultancy for a website where three different React templating libraries are in use
just why
 
the same kind of people that don't style their bootstrap components 😃
 
I had to reject that contract. I am too young to have gray hairs or even loosing it
 
same people that use ternaries like this stackoverflow.com/questions/66563898/…
 
3 nested ternaries ...
when writing code, people should think at its reusability and expandability as well 😐
 
I have a bit of code that used to work, but is not returning an error message in a loop that I don't understand. Clearly there's something going on behind the scenes I don't understand here.
The code is:
function onP5Editor() {
  console.log("Are we on the p5 editor?")
  parent = document.location.ancestorOrigins
  if (parent.length) { // this code is run on the editor
    return document.location.ancestorOrigins[0].includes('editor.p5js.org')
  }
  return false // not run on th eeditor
}
Does anybody know why just running this in the console could cause the following error?
p5.js says: There's an error as "postMessage" could not be called as a function (on line 2 in previewScripts.js [editor.p5js.org/previewScripts.js:2:60922]).
Verify whether "window.parent" has "postMessage" in it and check the spelling, letter-casing (Javacript is case-sensitive) and its type.
For more: developer.mozilla.org/docs/Web/JavaScript/Reference/Errors/…
I'd make this into a question..but I don't even know what to ask besides "Huh?!"
 
11:49 AM
*sobs* no semicolons
add a declaration modifier before your parent
 
@MitchellvanZuylen Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
@MitchellvanZuylen Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
because you're overriding the global parent ...
 
1 message moved to Trash can
 
That was it, overriding the parent.. I dind't know there was a global parent
Thansk!
 
12:05 PM
@VLAZ but they are confusing af!
i started learning generators because of redux-saga
 
12:24 PM
@MitchellvanZuylen always use declaration modifiers. If you don't, the engine attempts to associate it with an existing global variable or add it.
use const by default. That will save your sanity
 
1:00 PM
@VaibhavDwivedi I guess they are confusing until you see them in action. The vast majority of cases, they are not complicated: yield is like a return which can be called many times. That's really mostly it. You can do more with generators but it's rare. Most of the time a simple yield is all you get out of them.
You can then consume generators easily using for..of so you don't even need to pay attention to the iterator result object. for (const value of generator()) consumes the generator object and all of its yields.
 
1:58 PM
@VaibhavDwivedi I believe the function* doc should give you sufficient examples to comprehend that
that is where I have learned how it works.
is it useful? well ... used it one time outside experimental environment so far
 
o/
Morning everyone
 
@KarelG generators are very useful but only when you use a bunch already. It's a bit like asynchronisity - it only makes sense if it goes all the way up. If you are only working with fully materialised data, then array operations and loops are enough. If you have a single iterable, you may as well materialise it into an array. But if you don't want arrays all over the place and you want to work with/consume streams of values, then generators start to take over in utility.
It's a bit of a chicken and egg problem, though - if you don't use generators, you don't really have much of a reason to use generators.
Also, an issue that there are no good tools to work with iterables. We basically have for..of.
 
not for..in ? 😁
 
Which...again - not enough usage -> not a big demand for iterable tools -> no big reason to switch to generators
 
 
1 hour later…
3:12 PM
there is a proposal that caught my attention, Temporal: github.com/tc39/proposal-temporal
why did I have not seen this one before ._.
 
hey , is there is an equivalent to Jquary to do something like that in js vanilla ?
var htmlstuff = $('<div class="A">\
                            <div class="B">\
                                <img src="' + 'url.com' + '">\
                            </div>\
                            <div class="B"><b class="C">' + '<i class=" " aria-hidden="true"></i>'  + '</b>'+ '</div>\
                        </div>');

$(document).find('.someClass').append(htmlstuff )
 
jQuery is a library that uses javascript states internally
so ... yes?
 
yeah I understand but the only way I know how to do a similar code in JS is to create every element and append them to each other and finally to the someClass.

i wonder if there is a better way to do it as simple as jquery
I havent used Js for a little over a year, the closest thing that comes to my mind is innerHTML but not sure how to define aspect of it correctly
 
there is a DOMParser thing
you can pass html string in it
or .innerHTML but I AM AGAINST THAT
that is ... NAAAH ... should be used as last step or when injecting a big html chunk in an existing dom
 
I'm pretty sure jQuery just uses innerHtml for that
 
3:20 PM
@LoopingDev bleh
 
@KarelG oh, ok that is actually good , now we have 2 options instead of none lol so thanks
 
|| mdn template literalls
 
use DOMParser if there is a lot
 
@Cerbrus that is good to know so i could save all that in a var just like ( htmlstuff) and then append it ?
 
3:21 PM
or innerHTML but ....
 
@KarelG its just those few lines
 
I wouldn't do it like that, but yea, that's possible
 
and yes template literals to build up your html string
 
@Cerbrus great thanks I'll give them a try
 
there are frameworks that handles it for you, like Vue.js but it would be odd to import a whole framework for that small issue 😁
 
3:23 PM
@KarelG awesome , that is actually gonna save me a lot of headach
 
why is parseFromString not a static method?
 
@KarelG yea it would , I am trying to stick with the vanila as much as possible :)
 
And if it's for a once-off, you can just add a <script type="text/template"><... html template....></script>", and get the template HTML from there, and use JS to fill the content
 
@Cerbrus ohhh , very interesting !! , thanks a lot :)
@KarelG thanks for the help <3
 
@JBis history
the author wrote it with OOP in mind. Not a good choice
 
3:29 PM
were there other methods or something before?
 
no. TMK the intend was to expand it further, adding more functionalities but it got never picked up again
 
ah
 
AFAIK there is a addendum in the ECMA saying that it is "unfortunate"
/googles
eermmm I meant DOM specs... html.spec.whatwg.org/multipage/…
> The design of DOMParser, as a class that needs to be constructed and then have its parseFromString() method called, is an unfortunate historical artifact. If we were designing this functionality today it would be a standalone function.
 
    DOMParser.prototype.parseFromString('<html><h1>hi</h1></html>')

    Uncaught TypeError: 'parseFromString' called on an object that does not implement interface DOMParser.
thats annoying
 
people get around that with that ugly (new DOMParser()).parseFromString 😕
 
4:09 PM
reddit (and others) need to stop forcing their apps down our throats
i want to use their website not their app
 
They're just trying to serve you better!
 
reddit is blocking more and more functionality on their website and telling you to install the app
 
mobile user?
 
yes
 
I went with Joey
there are other apps that supports reddit. Joey is a nice app, but sadly they decided to add ads on it recently
but it is not much
 
4:18 PM
there is also a large memory leak on their mobile website makes it unusable sometimes
 
on reddit?
 
yes
 
First I have heard of that. I usually use the website and I have only noticed them pushing the app when accessed on a mobile device. Which is extremely annoying
 
Reddit uses pages. But when you go to the next page the previous page stays in memory for some reason.
 
What browser?
Or universally it is doing that?
 
4:25 PM
That is memory usage after two pages. If I reload that will go down because it won't have previous pages in memory.
@BeerusDev universally
 
Wow
I know chrome has a big memory leak problem
Or had. I have been using edge for about a year
 
same page after clearing
It's ridiculous
 
> chrome has a big memory leak, ima use edge instead
 
4:41 PM
Can't tell if that is a joke or you are being passive agressive which tends to be 90% of the time?
 
5:01 PM
Telling someone they're passive aggressive 90% of the time is passive aggressive...
 
By that standard, your response is passive aggressive
 
> fetch was slow, so i switched to axios
 
Now I just don't even know who you are referencing bc that was never said "Has anyone ever used the library Axios?"
"Thanks for the input I just came across it and was curious about it"
 
🤣
 
6:08 PM
Up arrow to edit on stackexchange chat is an underrated feature that all chat systems ought to adapt
 
6:19 PM
anyone elses space bar not working on desktop youtube search ?
 
hi
does anyone know the equivalent in js vanilla to this ?
`$(document).on('click',function(e){}`
basically i want to detect that the user has clicked away from an object to deselect it.
 
60
Q: Vanilla JavaScript version of jQuery .click

Duck in CustardSo maybe I'm just not looking in the right places but I can't find a good explanation of how to do the equivalent of jQuery's $('a').click(function(){ // code here }); in plain old JavaScript? Basically I want to run a function every time an a tag is clicked but I don't have the ability t...

 
that is not it but i think i found it
document.querySelector('.whatever').addEventListener('clickout', function(this){ })
clickout*
 
6:34 PM
no
oh.. clickout? wtf is that
 
think you're looking for mouseout or something
or err mouseup
 
$(document).on('click',function(e){} detects a click anywhere
including inside of the object you're trying to detect a click outside of
 
Yeah I think @LoopingDev mouseup and mousedown would better suit your use case
 
presumably it'd have an if statement checking if the target matches the node or anything inside it, and if it doesn't, then you do something.
 
@KevinB that was only part of an example that I am trying to understand , the rest of the example narrow it down based on the mouse distance , sounds a bit complicated to me but again i dont use JQ
@lovgrandma sounds good , I will look into it, thanks for the tip :)
hmm that actually sounds more like what I'm doing.

I'll look into it as well
thanks a lot :)
 
6:45 PM
There's a lot of ways to solve this one in particular
 
Yeah I've had a similar situation. Mouseup fires as soon as the click is done which is useful for immediately deselecting something. But if I understand what you're trying to do, you want the thing to be selected after the person unclicks. In any case I find it better to bite the bullet w/ jquery: use the click event listener and use $.contains(element in question, e.target)
 
for example, mouseout/mousein enables/disables a flag, binding on document and preventing propagation within the target element, document click and an if statement,
i would take the simplest route possible, which IMO is just one click event on the document
 
Anyone have any experience setting up https locally with react?
Im using "set HTTPS=true&&react-scripts --max_old_space_size=8192 start" in my react package, but the certificate is invalid on the front end. It says "Issued to: localhost" but it says its not trusted
 
@lovgrandma why do you need https?
 
I would prefer to use it to match my production environment on ec2
 
6:49 PM
And it's untrusted because it's self signed. You need to manually trust it.
@lovgrandma 99% of time you don't need to. Are you using a specific feature only aval in https?
 
hmm... yeah thats fair. I haven't thought this through. Its just tedious because I have to edit my separate node.js application and set it to "http" instead of "https" for the imports
or err... i could just do const server = conditional to load http or https
because http cant talk to https
react -> node.js
 
hmmm..
is it not normal to just have your webserver handle https
forward to node
 
i should use apache you suggest?
ive just been doing node app and running it
 
that's what i've always done
 
im confused
 
6:52 PM
let apache handle all the static file serving, then forward the rest to node
apache handles the cert
 
is your dev client connecting to prod backend?
 
No so I have a dev client and dev backend
To just keep it all separate
 
both should be on http
 
so in light of what you said JBi I think Ill just make the dev side both http
yeah
 
on prod, you should use a proper webserver such as apache or preferably nginx like kevin said and then proxypass
 
6:54 PM
yeah I will implement nginx. SSL is already working for production right now
minipost.app
Do appreciate the suggestion though @KevinB
 
7:10 PM
@lovgrandma @KevinB i think that is the equivalent to it in js

addEventListener("click", ({target}) => {
        if(!target.matches(".someClass")){
            console.log('clicked away');
})
})
 
Yeah thats pretty much wthat you should do
 
thanks :D
 
bleh i don't like that destructering
 
i don't like most destructering
 
me neither ^^
 
8:11 PM
@FélixGagnon-Grenier what is going on with stackoverfiow.com?
 
huh, didn't think someone would notice. I had to let go of the domain temporarily
 
temoprarily lol
its fine
 
somebody picked it up
 
8:12 PM
amazon client picked it up
 
guess all that traffic over the years convinced them this was a praised domain
 
or spam or someting
 
maybe they want to steal our souls
 
it has nothing on it
 
I'll make sure to burn some incense to protect against any unwanted soul activity
 
8:16 PM
I wanted to play another aprils fool joke but it won't happen
with JS I could make it do anything but that's okay
 
8:27 PM
Hey guys
I seem to have a problem with Next.js routing
 
most unfortunate
 
I generate a static build
and deploy it on the same vps that my api is hosted on (with nginx)
0
Q: Static Next.js App deployed with Nginx breaks routing

Hassan AlthafProblem: I have a Next.js application where when I go to the homepage, and click a navigation link, it works perfectly fine. However, if it goes to a direct URL like "/users/reset-password?token=ca16af8041f8fdd91d5e5464da1fb9e83c687abc9d60720f20db51fb5c240809&id=1" from an email, it doesn't activ...

Any help would be highly appreciated :D
 
8:54 PM
I want to create a object that contains an action that contains a {string} type and a {Object | String | Number} payload. So I'm trying something like action = {type: type, payload: {...payload}}
and that works when payload is an Object, but not when it's values...
Feels like I have seen some neat way to write this, but I don't recall..
 
i mean
ideally a method should never return either type x or y
 
mm, but so payload: typeof payload === "object" ? {...payload} : payload ?
 
there are generally ways to make something work, one can count on that
now, whether these ways should make us reconsider or not...
 
9:09 PM
well so how would you recommend to do it? always send a full object? with some kind of fake key?
like {payload: {value: 32}}
 
depends on the usecase
Why would it even be a number, or a string, or an object
sounds like a function that is too generic
 
thing is that it's a communication thing, and I want to be able to send actions to a backend
so we kind of want to keep it as general as possible
 
any
 
?
 
9:16 PM
yes.
 
so, here's the thing: this function you are describing, you don't know what it returns, you can assume that it will only ever return a string, or a number, or an object, but because this is interacting with an interface outside of your application, you can't guarentee that. The purpose of a type here is to enfoce how you interact with it in your code
but if you don't know what it is... what good is that
the code that calls the function will assume that it's what that endpoint should return
at that point you can apply a type to it
 
well.. it's me that sends the object. so it's up to the receiver to interpret it
 
because you expect it to be an object, with properties x y and z
but prior to that, it's... anything, because anything can call it
adding a type to it at that point other than 'any' doesn't really add any value
but, tbf, take my opinion here with a large grain of salt, i haven't written typescript in a year and a half, maybe 2
 
but the type tells the receiver how to interpret it.. he knows that if it's a _setVisible_ type, he should read the payload as a bool, and if it's a _setValues_ he should read the payload as a object.
I have never written typescripts so I'm thankful for any input :)
 
i did have a similar scenario in my code... trying to recall how i handled it
effectively, the body portion of an express request
i'm pretty sure i didn't type it at all until it actually reached a controller
the point where it mattered what it was
 
9:26 PM
@Markus can you give example of function?
It sounds to me you want to use generics
function foo<T = any>(payload: T){ return {type: "bar", payload}}
Damn mobile
 
I'm thinking about where I made it look like it was a function, sorry I must have been unclear.
 
> I want to create a object that contains an action that contains a {string} type and a {Object | String | Number} payload.
i interpreted "action" as method
 
Ahaa, I see. no it was just a name of a variable. action = {type: "foo", payload=32} or action={type: "bar", option1: "no", option2: "good"}
but thinking about it, I agree that this seems a lot simpler action={type: "bar", payload: { option1: "no", option2: "good"}}
 
i don't get the question
 
I see that my initial question is wack...
let's just ignore everything that I have said except for the thanks.
 
9:42 PM
ok
 
posted on March 10, 2021 by Bindu Suvarna

 Hi, everyone! We've released Chrome Beta 90 (90.0.4430.20) for iOS: it'll become available on App Store in next few days. You can see a partial list of the changes in the Git log. If you find a new issue, please let us know by filing a bug. Bindu Suvarna Google Chrome

 
anyone else really like cloudflare as a company?
i'd say they are one of the best if not the best tech companies around
 
10:01 PM
soo... next stupid question then. is there any quick way to declare my action with or without the payload object depending if it's defined? like if I have no payload, the action should be action = {type: "foo"} but if there is a payload it should be action={type:"goo", payload: payload}
 
10:52 PM
|| mdn ternary operator
 
Invalid command! Did you mean: terraria, restart, erase? Try help for a list of available commands..‍.‍
 
we've had no real issues with cloudflare, though, they like to push their paid products
 

« first day (3798 days earlier)      last day (1157 days later) »