« first day (3052 days earlier)      last day (2121 days later) » 

02:16
@rlemon sorry for late response, can you explain it a little bit more?
02:34
@deostroll It's also known as banker's rounding. Instead of always rounding x.5 up or down, it rounds it to the nearest even integer.
02:53
Ok
 
5 hours later…
08:06
does the latest Node 11.10 have tail call optimization? Or do we still need trampolines?
var fs = require('fs');
var path = require('path');
var walk = function(dir, done) {
  var results = [];
  fs.readdir(dir, function(err, list) {
    if (err) return done(err);
    var pending = list.length;
    if (!pending) return done(null, results);
    list.forEach(function(file) {
      file = path.resolve(dir, file);
      fs.stat(file, function(err, stat) {
        if (stat && stat.isDirectory()) {
          walk(file, function(err, res) {
            results = results.concat(res);
            if (!--pending) done(null, results);
217
Q: node.js fs.readdir recursive directory search

crawfAny ideas on an async directory search using fs.readdir? I realise that we could introduce recursion and call the read directory function with the next directory to read, but am a little worried about it not being async... Any ideas? I've looked at node-walk which is great, but doesn't give me j...

Is there any reason why if (err) return done(err)
has return, while
if (!--pending) done(null, results); doesn't ?
08:44
Hi, I need help using the NYT API
I'm very inexperienced with API, but I know that for the NYT, the URL Endpoint I want is api.nytimes.com/svc/topstories/v2/science.json?api-key=yourkey
I already have my API key, but the problem is how do I incorporate that into my code?
Can I use document.getElementById to replace the h1 text of the div by the article's name? If so, how can I retrieve the article's name in the first place?
Yeah, not much I know
@KendallFrey Hi, any ideas?
 
3 hours later…
11:34
Can someone explain what is going on here? w3schools.com/cssref/…
p:nth-last-child(4n+0)

> The third and seventh paragraph is targeted ... why?
First p: 4*(0)+0 = 0 (NOT COLORED)
Second p: 4*(1)+0 = 4 (NOT COLORED)
**Third p: 4*(2)+0 = 8 (COLORED ?! )**
Fifth p: 4*(3)+0 = 12 (NOT COLORED)
 
2 hours later…
13:55
@Aurelius TCO was dropped from the specs.
Node 11 doesn't have it, and it's incredibly likely that neither will 12, 13, 14 ....
14:15
can I map and filter with a single function?
@Aurelius Technically, yes. Practically, no.
14:30
var reduced = options.reduce(function(filtered, option) {
  if (option.assigned) {
     var someNewValue = { name: option.name, newProperty: 'Foo' }
     filtered.push(someNewValue);
  }
  return filtered;
}, []);
61
Q: Map and filter an Array at the same time in Javascript

Daniel Calderon MoriI have an array of objects that I want to iterate over to produce a new filtered array. But also, I need to filter out some of the objects from the new array depending of a parameter. I'm trying this: function renderOptions(options) { return options.map(function (option) { if (!optio...

@MadaraUchiha thanks, but isn't what that reduce would do?
It's been two days non stop stuck with an asyncronous function
@Aurelius That's the "technically" part, yes.
I can't go forward
I just need to asyncronously read every file of folder recursively
What's the end objective?
If I send a piace of simplified code would you please provide some tips?
I believe I am very close and I just need a hint
the goal is to retrieve data and status about every file in a directory tree
and I need to read them and see what's inside, but it needs to be fast
the parallel loop from this answer is the fasted I have found
*fastest
349
A: node.js fs.readdir recursive directory search

chjjThere are basically two ways of accomplishing this. In an async environment you'll notice that there are two kinds of loops: serial and parallel. A serial loop waits for one iteration to complete before it moves onto the next iteration - this guarantees that every iteration of the loop completes ...

 
2 hours later…
16:12
how come I have a value that can be either a promise or a normal value?
How can I know how to hanlde it?
By checking whether it's a promise or a value
@KendallFrey thanks, even stranger thing, why does new Set(), when put inside an async reduce callback as initvalue of the acumulator doesn't get carried over between iterations?
instead if I just replace new Set () with [] and add with push
it works?
I have absolutely no idea what you're talking about
I am preparing a MWE
simple
@KendallFrey here is is
function test() {
  return [1,2,3,4].reduce(async (valuePromise, val) => {
    const status = await valuePromise;
    status.array.push(99);
    status.set.add(88);
    return valuePromise;
  }, {
    array: [],
    set: new Set(),
  });
}
it prints
{
  "array": [
    99,
    99,
    99,
    99
  ],
  "set": {}
}
instead we should also see
four times 88
in the set as well
16:28
Works fine for me
{array: Array(4), set: Set(1)}
array: (4) [99, 99, 99, 99]
set: Set(1) {88}
__proto__: Object
@KendallFrey okay now I am getting this as well
{ array: [ 99, 99, 99, 99 ], set: Set { 88 } }
but with this
  test().then(f => {
    console.log(JSON.stringify(f, null, 2))
  });
I get the wrong result
I'm going to guess that's because stringify doesn't support sets
okay thank you, I didn't know about that
const readFile = promisify(fs.readFile);
is there any performance disadvantage in doing that?
Can't imagine why there would be
16:48
@Aurelius Completely insignificant when compared to filesystem access.
17:23
Someone know how to draw a parabola between two points, so the distance of any point in the parabola is the same between it and the first or it and second point?
@EnderLook What
I want to draw something like this picture -> ams.org/featurecolumn/images/august2006/parabola.jpg
@EnderLook There are no two points here...
@MadaraUchiha mmm, that could explain why its not working...
The red dot (X, Y), and the line purple (Y) + red dot (X), I think I am trying to do
I am trying to use quadraticCurveTo from canvas, but I'm not sure if that is the correct tool...
 
2 hours later…
19:13
Hi all, I need help using the NYT API;
I'm trying to use their Top Stories API to retrieve the latest news. I want to replace the h1 text of the div with the title of the NYT article. I'm thinking I can use document.getElementById to do that, but I have no idea how to retrieve an article name in the first place using the API. However, I do have an API Key, and I know the URL Endpoint I'll use is api.nytimes.com/svc/topstories/v2/science.json?api-key=yourkey
@MadaraUchiha Hi, any ideas?
19:41
@BigCoder101 Please don't ping people to ask for help, that is called help vampire. Just ask the question in the chat without pinging anyone, if someone knows and is free, it may help.
OK, Sorry. Don't wanna be a help vampire
Weird. api.nytimes.com/svc/search/v2/… returns invalid API Key.
Oh nevermind; removing brackets did it
WOW IT'S WORKING!!
I DID IT
I. DID IT
20:06
!!magic
(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。 ᵀᴴᴱ ᴳᴬᴹᴱ

« first day (3052 days earlier)      last day (2121 days later) »