« first day (2829 days earlier)      last day (2343 days later) » 

00:10
how's it going guys?!
 
7 hours later…
06:59
hey guys is there someone who is familiar with electron.js
Can i use node.js package with electron.js
07:31
Why is Object.keys(object)[Object.values(object).indexOf(key)] faster than Object.entries(object).find((v)=>{return v[1]==key})[0] ?
07:57
When using Socket.io what security should I use to prevent session hijacking.
or is it already just handled in the package?
 
2 hours later…
10:14
@JennaSloan my first response was: you have too much time in your hands
but my best guess is, that Object.prototype.find might just be pretty slow in general
10:35
@JennaSloan I think in the former, all of them are heavily optimize and run in C land, while in the second, some javascript has to happen. You're also invoking == instead of ===, otherwise it could probably have been optimized further
also, you don't care about Object.entries, you should use Object.values, which will also speed it up
and then a .indexOf will be semantically very similar to a .findIndex(x => x === y), but much faster
oh wait, you do care about object.entries
Chat page come from 90's
11:43
try "so dark chat"
it's an extension by one of the main users, which makes it more modern
Knu
Knu
Is there a question on stackoverflow relating to multipart/form-data to FormData instance?
I couldn't find it but it probably exists.
I am talking about the raw bytes conversion/transformation.
12:10
Using Server-Send-Event cause my page single javascript page used 800 mb of memory after a while....
I think the problem is that the connection not close ...
any help?
when i use evtSource,close() connecte closed..but then page not update ....i think the uestion is how open connection after close it?
Here on " developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/…; sayed --> "By default, if the connection between the client and server closes, the connection is reset" reset means connection again? how this happen. and if connection reset...why page using this amount of memory?
Can someone clarify what is wrong with my method signature that it requires the empty `.then()` in order to compile (Typescript, targeting ES6)?

class Test {
    getData(): Promise<MediaStream> {
        return null;
    }

    init(): void {
        this.getData()
            .then() // Will not compile without this
            .then(stream => console.log(stream))
            .catch(err => console.log(err));
    }
}
@JeroenVannevel Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
@JeroenVannevel it shouldn't compile anyways
this.getData() returns null which doesn't have a .then property on it
or do you not have strict null checks on?
It's a minified example to stub the method -- I'm assuming the method signature is what really matters
Actual implementation is

return navigator.mediaDevices.getUserMedia({
            audio: true,
            video: true
        });
What are the dom.d.ts types for getUserMedia?
12:24
getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>;
and what is the compile time error you get without the additional then()?
> "supplied parameters do not match any signature of call target: expected 0 parameter(s) but was invoked with 1 parameter(s)"
That just seems wrong
Hence my extreme confusion :D
Do you maybe have clashing Promise definitions?
12:28
How would I check that? I've literally just created a new project so it should have the bare minimum
unlikely then
Was just thinking you might have @types/bluebird or something in there as well
That's really weird
Does google tell you anything?
Similar?
This chat was my last resort after a lot of googling and trialling. Though that being said.. disabling my R# seems to have fixed it
Can't believe I hadn't seen that thread before
Thank you so much @phenomnomnominal!
goddamn resharper :(
Glad I could help though!
It seems like my PC has an April 2017 version of R#.. I'm assuming after updating it will be fixed.
12:57
Yeah sounds about right!
 
2 hours later…
Knu
Knu
14:32
Anyone knows why (function() {}).name is '' but (new Function).name is "anonymous"?
Shouldn't both return the same string?
Since anonymous is not a reserved name, you cannot rely on "anonymous" either; so the only real use case is to distinguish the 2 ways of creating an anonymous function.
puzzling
15:10
@Knu that's just the language rules
What do you mean by "anonymous function"?
If you assign it to somewhere - that assigns .name
Perform SetFunctionName(F, "anonymous"). under CreateDynamicFunction 19.2.1.1.1
can anyone help with my question?
0
Q: How to bind a checkbox to an already existed checkbox?

Mohammadi have a Product attribute Checkbox on my website and it will update products list with ajax and javascript onchange event.(I've added all of my code on jsfiddle Here) HTML : <input data-option-ids="1358" id="specification-input-21-1358" type="checkbox"> <label class="filter-item-name"...

There is no way to do this "in general" - just listen to when one changes and update the other or use a library with data binding
Knu
Knu
15:31
I am saying that function anonymous() {} is allowed.
Which means that returning "anonymous" doesn't guarantee anything.
The question is why the discrepancy.
@Knu well, there is no good reason
@Knu and the fact you can't tell if a function was dynamically constructed is by design, although you can enable CSP and disallow dynamic creation
What is your actual goal @Knu ?
Or are you asking why the (relatively recent) change to name function constructor created functions "anonymous"? That's just in order to name more functions.
const foo = (function() {});
foo.name; // "foo"
(the tl;dr is one browser did it and then web compatibility)
Knu
Knu
16:06
nice find
Gecko is responsible
@BenjaminGruenbaum I have a function() {} fallback and I was wondering if Function() would be equivalent.
It's not obviously :)
Well, for more than one reason, .name being one :)
Knu
Knu
What are the other reasons if it remains empty?
It doesn't remain empty, it gets deduced from context.
If you assign it somewhere it gets that name, although that's pretty new behaviour too
Knu
Knu
empty as in no string passed as the first argument
I don't think people rely on .name anyway since everyone uses minifiers and minifiers don't care about .name
@Knu not sure I understand that question. (There are other differences between function() {} and Function - not in .name necessarily)
Knu
Knu
16:12
What are these other differences?
Well, if CSP is active than new Function doesn't work - since new Function is commonly (if you can say that) used for optimizations by dynamically constructing functions - libraries that utilize it have to fall back to another method.
Moreover, the async function constructor, generator constructor and async iterator constructor are not exposed
Knu
Knu
yeah Id need a try catch
Well, not just, you'd need to actually implement it twice
Once with dynamic construction and once without. On the server new Function isn't great if you can vm.runInContext - it really depends on what you're doing
Here's an example from a library I worked on and help maintain: github.com/petkaantonov/bluebird/blob/master/src/…
Knu
Knu
on older browser new was necessary
Knu
Knu
16:16
bluebird yup I used it
Function is equivalent to new Function
Looking at the older spec (es5) see the function constructor used as a function
Knu
Knu
try Error() and new Error() on old browsers
ull see
> When Function is called as a function rather than as a constructor, it creates and initialises a new Function object. Thus the function call Function(…) is equivalent to the object creation expression new Function(…) with the same arguments.
@Knu that's different, there is a difference in how stack traces behave.
You'd get an extra stackframe without the new
Knu
Knu
mmmh
I am saying that just Error() wasn't supported IIRC.
It's no longer true, but how stack traces work wasn't specified
@Knu it was, the problem was that stack traces were not standardized so while the spec said they behave the same in practice you got a different stack trace
> When Error is called as a function rather than as a constructor, it creates and initialises a new Error object. Thus the function call Error(…) is equivalent to the object creation expression new Error(…) with the same arguments.
Knu
Knu
16:19
That's today yeah :)
It was supposed to do exactly the same thing - but in practice since err.stack wasn't well specified it didn't
@Knu that's a direct quote of the ES5 spec from here - that was released 9 years ago in 2009
Knu
Knu
When I say old, I mean it.
Oh, even in 2009 browsers differed - but that's because of err.stack which wasn't even in the spec
Knu
Knu
since you seem knowledgeable
Actually, that quote in ES5 comes directly from ES3 - so it's been that way since 1999
Knu
Knu
16:22
Do you know any other string returned by typeof outside of "unknown" and the standard ones?
@Knu Only useless information and language lawyering.
@Knu "unknown" is not allowed by JavaScript, host objects may return whatever they want though.
Knu
Knu
yeah and Id like to know all the implementations quirks
Looking at the recently released ES2018 See all values typeof may return
Namely, see:
> Object (non-standard exotic and does not implement [[Call]])
Knu
Knu
> Must not be "undefined", "boolean", "function", "number", "symbol", or "string".
doesn't help much :)
I want a whitelist for an ESLint plugin
In JavaScript, the specification defines how JS objects behaves but some stuff isn't JS objects it's host objects
That is, it doesn't come from the language (like Array or Error) - it comes from the platform!
@Knu that's one of the crucial parts in JavaScript. JavaScript (with the exception of promises since ES2015) always runs code synchronously. Everything "async" isn't JavaScript and comes from the platform.
The platform is either Node or the DOM or something else (like Rhino, Deno or whatever)
Knu
Knu
16:27
Deno? Never head of that one
It's something experimental, don't bother with it for the next 3-6 months.
I gave a talk about it recently - but basically it's something Ryan (original Node author) wrote for multi purpose safe tools (rather than fast servers).
It's on top of Rust and serializes calls with Flatbuffers rather than call into C like Node
Rhino (or Nashhorn) is just Java, lots of runtimes.
Knu
Knu
Rust sure has a momentum, having Mozilla backing sure helps
Well, over the years I stopped caring about what's picking momentum and started caring about what works well
Rust was picked because Go (which was picked initially) does garbage collection and two GCd languages don't mix well
Knu
Knu
Id pick nim-lang.org over Rust
16:50
@AlishaSharma yes you can. You have to call electron rebuild after a package install
17:07
i am having troubles with a dropdown menu. .hover gets triggered on both blue and red divs jsfiddle.net/z2dux1ko/12 .off(".child") didnt work
is there a easy fix or an option to stop this behavior ?
17:26
event.stopPropagation() wasnt working on parent on its own. but when i add a second hover on child with again event.stopPropagation(). it worked
lovely :D
 
1 hour later…
18:29
can some one help me here : Message
18:50
huh, running into an interesting quirk
I have some code like this:
const session = new Proxy(req.session, {
  set(obj, attribute, value) {
    const property = someMagicOnAttribute(attribute);
    console.log(property, obj)
    obj[property] = value;
    return true; // probably bad but hey
  }
});

session.authed = true; // modAuthed, {...}
session.xyz = 123; // modXyz, {..., modAuthed: true }
session.id = 123; // modId, {..., modAuthed, xyz } TypeError
I'm getting the same error as in here: stackoverflow.com/questions/46227721/…
now, a reasonable assumption is that modId is somehow protected, but req.session.modId = 123 works just fine
so from what I understand, it's not the same problem as in that Q
@BenjaminGruenbaum maybe you can make sense of this/
?
I'm going to try to make something reproducible
but I don't really know how, so I'll start with stripping things down
19:07
huh, this also has issues: glitch.com/edit/#!/paper-suggestion
ok, I think I figured it out
but it feels really wrong, as a language thing
the proxy works fine on empty objects and similar, it's just req.session
and modId is not protected, but id is
so the proxy is somehow checking for the information on req.session.id, while I'm actually only considering req.session.modId, because I use proxy.id or similar
which I now realize is kind of what the answer on the Q was saying
now, an easy solution is to use something other than session.id, like session.lid for localId, but that feels hacky
although it's probably what I'll do
does this count as a spec bug?
19:38
scrapped my first webpage today
:)
you mean scraped?
yeap
that
how's it going towc
how much time do you have?
20:38
as in?
20:54
why is adding prototype functions looked down on
??
21:11
As opposed to?
We have sugar for prototype stuff, and it looks cleaner, if you're talking about classes
Manual prototypes are just old
Like using var
Howdy
 
2 hours later…
23:13
hi william
Array.prototype.random = function () {
    return this[Math.floor((Math.random() * this.length))];
}
Some guy on SO said it was wrong to add a prototype this way to array
im not sure why.
it works
It's not wrong, just very much frowned upon.
As you're adding to the api of a native object, which then means there's functionality that's not documented in a place that's unexpected. A more dev-friendly approach would be to write that as a function that accepts an array, and returns an array
I frown upon the artificial distinction between native and library functions
Alternative language?
Another reason not to add to the native object prototype is that there's no guarantee that the name you've used won't later be used by the language itself. Suppose the spec changes to include a native random method on the Array prototype. Now you're overwriting a native method
/native/baked-in/s
Ahh i see
that makes total sense
I'll change it
:)
@KendallFrey How about specced method? Or divine method?
23:26
Never heard of those terms
I'm spitballing. What would you call it to avoid ambiguity?
call what?
native vs library functions
Any of you guys use the events module in nodejs?
if an event is fired and there is no listener/handler associated with that event. An error event will be emitted and halt the node js process right?
Really? That seems unlikely
23:32
Im not sure. I havent tested it. I'm going to test it tomorrow.
Then what makes you think so?
If an EventEmitter does not have at least one listener registered for the 'error' event, and an 'error' event is emitted, the error is thrown, a stack trace is printed, and the Node.js process exits. nodejs.org/api/events.html
It's only for the error event, my bad.
ah that makes some sense
Well i gotta go
cya man
or woman
:)
I'm a person

« first day (2829 days earlier)      last day (2343 days later) »