These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Nov 2018
Dovydas Stirpeika
@Giveback007
Nov 05 2018 00:02
they allow you to see the original source code
when debuging
Pagnito
@Pagnito
Nov 05 2018 00:03
but dont we alrdy have pretranspiled code we working on anyways?
the ts or tsx files
Dovydas Stirpeika
@Giveback007
Nov 05 2018 00:03
it can be useful when setting breakpoints
also if you are debugging with vs code that the only way to get it to work
there's other examples that go in to depth in the use of source maps
Pagnito
@Pagnito
Nov 05 2018 00:04
do i need source maps if im working wit ts?
like im pretty sure im gonna have to adapt it but for now as im learning ts do i need it?
Dovydas Stirpeika
@Giveback007
Nov 05 2018 01:13
only if you are debuging
红鲫鱼
@zzr716
Nov 05 2018 02:07
?
Pagnito
@Pagnito
Nov 05 2018 03:19
@Giveback007 hey so if we using ts compiler, we dont need babel basically righT?
Pagnito
@Pagnito
Nov 05 2018 03:38
@Giveback007 setting up ts seemed alot easier than babel with all babel changes constantly happening
and all the packages
Pagnito
@Pagnito
Nov 05 2018 04:12
@Giveback007 yo
Claudio Restifo
@Marmiz
Nov 05 2018 05:17
@Pagnito if you only have TS files, then yes. But if you have mixed, (or other js extensions that uses babel, like react for example) then you still need babel.
There's a @babel/typescript preset in that case
Pagnito
@Pagnito
Nov 05 2018 05:18
i dunno im using react with typescript right now without babel
Claudio Restifo
@Marmiz
Nov 05 2018 05:19
how are you transpiling jsx?
Pagnito
@Pagnito
Nov 05 2018 05:20
ts-loader
"jsx": "react",
in the tsconfig
Chris Cullen
@123xylem
Nov 05 2018 11:27

https://jsfiddle.net/zv1w6j9u/1/
I have html rows with data attributes
I filter these with checkboxes that add values to an array and then regex match those values with the data attributes - Showing only the rows that match the values.

This works for 1 filter at a time eg - data-payments but I'm struggling to combine the filters so if data-payments is a match it can still hide or show if data-games isnt a match

Shubham soni
@shubhamsoni2617
Nov 05 2018 14:44
If window is an object than why does this isn't working a:'hi'; console.log(window.a); ??
Christopher McCormack
@cmccormack
Nov 05 2018 14:57
@shubhamsoni2617 should be a = 'hi' if you want it attached to the window object
or window.a = 'hi'
I'm not sure why typing a: 'hi'; even works
Shubham soni
@shubhamsoni2617
Nov 05 2018 15:06
might be because we are defining new property on window object...!!
Mohammed Boudad
@matrixersp
Nov 05 2018 15:11
Hey everyone, can someone tell me why I'm getting this error?
Uncaught TypeError: WebSocketServer is not a constructor
When I try this:
const WebSocketServer = require("ws").Server;

class Server {
  constructor(port) {
    this.server = new WebSocketServer({ port: port });
  }
  //...
}
Christopher McCormack
@cmccormack
Nov 05 2018 15:11
try removing new
Mohammed Boudad
@matrixersp
Nov 05 2018 15:12
I did, it tells me it's not a function
Christopher McCormack
@cmccormack
Nov 05 2018 15:13
then I imagine it's not being used correctly
are you following a guide?
Tom
@moT01
Nov 05 2018 15:15
good morning
Christopher McCormack
@cmccormack
Nov 05 2018 15:15
@shubhamsoni2617 you don't assign values to an object using that syntax
Mohammed Boudad
@matrixersp
Nov 05 2018 15:15
I'm trying to follow the docs in github, here's a simple use case of ws
const WebSocket = require('ws');

const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
    console.log('received: %s', message);
  });

  ws.send('something');
});
Christopher McCormack
@cmccormack
Nov 05 2018 15:15
@moT01 heya
@matrixersp you should follow how they did it, you may not have this they way you're invoking it
you may be able to do const WebSocketServer = new require("ws").Server({port: 8080}) but not sure, I haven't done it that way before
Tom
@moT01
Nov 05 2018 15:18
whats up
Christopher McCormack
@cmccormack
Nov 05 2018 15:19
just looking over some PRs during breakfast, you?
Tom
@moT01
Nov 05 2018 15:22
same
Mohammed Boudad
@matrixersp
Nov 05 2018 15:23
@cmccormack I tried it with ws version 5.2.2, it worked but I got two warnings
Christopher McCormack
@cmccormack
Nov 05 2018 15:23
is that the version you are following the guide/docs for?
Mohammed Boudad
@matrixersp
Nov 05 2018 15:27
They are not specifying which version they are using in the doc, I believe it's the latest (6.1.0)
Chris Cullen
@123xylem
Nov 05 2018 15:56
function filterPay(val){
        // target Rows
            $(".loading tr").hide().filter(function() {

        var rtnData = "";
        //make approved regex based on given value
        var payApproved=    new RegExp(val.map(x => x.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')).join('|'), 'i');

           //make rtnData array? consisting of rows that match regex
            rtnData = (
                        $(this).attr("data-payment").match(payApproved)
            );

        return rtnData;

        }).fadeIn("fast");
    }
Hi guys Is it possible for me to get the ID of the matching row in rtn Data rather than the whole row
Jason Luboff
@JLuboff
Nov 05 2018 16:04
Morning :wave:
Christopher McCormack
@cmccormack
Nov 05 2018 16:05
@JLuboff whatup
Jason Luboff
@JLuboff
Nov 05 2018 16:05
Just getting the day started..you?
Christopher McCormack
@cmccormack
Nov 05 2018 16:09
Same, digging into the backlog of emails
there are some posts already on /b/general
@123xylem this doesn't look like anything to me, do you have this code on codepen or codesandbox so we can play with it?
Chris Cullen
@123xylem
Nov 05 2018 16:12
It is just a filter that targets rows and uses a regex value to see i those rows have a data-attribute that matches the regex
Christopher McCormack
@cmccormack
Nov 05 2018 16:13

@123xylem also can you elaborate on

get the ID of the matching row in rtn Data rather than the whole row

Chris Cullen
@123xylem
Nov 05 2018 16:13
it then shows or hides the rows
SO i want the data attribute data-rows (which is the unique Id) instead of the whole row to show or hide
Basically I want to filter rows based on a data attribute and if they pass Show a certain data attribute
Christopher McCormack
@cmccormack
Nov 05 2018 16:15
@123xylem rows of what? Is there supposed to be a table visible?
Chris Cullen
@123xylem
Nov 05 2018 16:16
Yes there is a table but its just html rows
Christopher McCormack
@cmccormack
Nov 05 2018 16:19
are we looking at different fiddles?
this doesn't have any table elements
Jason Luboff
@JLuboff
Nov 05 2018 16:20
@cmccormack So far testing seems good..but.. I find the example usage confusing.. is that just to get the JSON response?
No where on the page do I see that it should be url/b/threadName
Christopher McCormack
@cmccormack
Nov 05 2018 16:21
submitting the thread should redirect you to the board
but yeah I guess I can flesh out the home page a bit, focus was on the boards
Jason Luboff
@JLuboff
Nov 05 2018 16:22
Ya so far thats the only issue I see
Christopher McCormack
@cmccormack
Nov 05 2018 16:25
@JLuboff thanks for checking it out
FCC has the templates built for you if you want for this project but I wanted to try it myself, more work than I expected
Jason Luboff
@JLuboff
Nov 05 2018 16:26
You probably learned more by not using the template though!
Christopher McCormack
@cmccormack
Nov 05 2018 16:27
that's the goal right?
:)
I learned I would much rather use React than html/pug that's for sure
but the pug conditionals and loops were pretty easy to use so not too bad
Jason Luboff
@JLuboff
Nov 05 2018 16:31
Hah
Than you should have used React!
Christopher McCormack
@cmccormack
Nov 05 2018 16:32
hindsight my friend
thought it would be super quick
I think my next project like this I definitely want to figure out frontend testing
@JLuboff 5be06d6dcd1e31005d209a05 I know that's you!
Jason Luboff
@JLuboff
Nov 05 2018 16:36
@cmccormack You have no evidence
Christopher McCormack
@cmccormack
Nov 05 2018 16:37
@JLuboff you don't know what I'm storing in the backend... :grin:
man that didn't sound right...
Jason Luboff
@JLuboff
Nov 05 2018 16:40
Disturbing
Jason Luboff
@JLuboff
Nov 05 2018 16:47
@cmccormack So does that mean you have all the certs now?
Christopher McCormack
@cmccormack
Nov 05 2018 16:47
I never submitted the data viz one, wanted to go back and complete them with the test suite first
but pretty much
I think one more to update
Jason Luboff
@JLuboff
Nov 05 2018 17:09
Good deal
Christopher McCormack
@cmccormack
Nov 05 2018 17:10
@JLuboff what about you, jumped back in yet?
Oh I guess I did complete FCC, just got the email
Jason Luboff
@JLuboff
Nov 05 2018 17:15
No... no time man.. at this point I'm 3 active work projects in.
Oh, Congrats!
Christopher McCormack
@cmccormack
Nov 05 2018 17:16
Thanks man!
I guess it will include your legacy cert
I never submitted the new Data viz
Jason Luboff
@JLuboff
Nov 05 2018 17:16
I imagine there are some projects overlapping?
Tom
@moT01
Nov 05 2018 17:18
@cmccormack got it all done? nice job
Christopher McCormack
@cmccormack
Nov 05 2018 17:18
@moT01 thanks man
@JLuboff I think if you had it already they don't make you get the new one
Tom
@moT01
Nov 05 2018 17:22
there's quite a few overlapping projects - if you turned in one on the old site, you don't need to turn it in again - or change it to pass the tests
Christopher McCormack
@cmccormack
Nov 05 2018 17:22
yeah just doing that in case members have problems with those tests passing
It's been good seeing how the tests work, especially for the D3 projects
Tom
@moT01
Nov 05 2018 17:24
meaning how the interface sort of works - or how they were actually like built
Christopher McCormack
@cmccormack
Nov 05 2018 17:33
Sorry how the tests actually test the functionality
like how it tests that the tooltip works
Brad
@bradtaniguchi
Nov 05 2018 19:32
hullo, hows everyone doing today
Jason Luboff
@JLuboff
Nov 05 2018 19:32
Doing alright. Studying and coding.. you?
Brad
@bradtaniguchi
Nov 05 2018 19:36
tackling the last few tasks of this refactor.. The nasty stuff I saved for later, and now is later :/
Jason Luboff
@JLuboff
Nov 05 2018 19:38
fun stuff
Brad
@bradtaniguchi
Nov 05 2018 19:40
eehhhhhh
Christopher McCormack
@cmccormack
Nov 05 2018 19:53
@bradtaniguchi heya
is that your job, fixing bad code?
Brad
@bradtaniguchi
Nov 05 2018 19:56
For the last few months yes
I've made a number of performance improvements, added some new features, and fixed a number of security issues
Jason Luboff
@JLuboff
Nov 05 2018 20:05
Were you the one who originally created all those issues? :trollface:
Brad
@bradtaniguchi
Nov 05 2018 20:06
Nope, thank god XD
Jason Luboff
@JLuboff
Nov 05 2018 20:07
Suuureee
Brad
@bradtaniguchi
Nov 05 2018 20:12
Hey, I was on the front-end side, not knowing the truth that lied beneath hehe
Jason Luboff
@JLuboff
Nov 05 2018 20:14
No judgement here (or is there)
Dovydas Stirpeika
@Giveback007
Nov 05 2018 20:17
@Pagnito you can use webpack and ts loader
@bradtaniguchi wouldn't it be "the lies" beneath ?
@JLuboff hey man, how's it been
Jefferson
@jeffersonnnn
Nov 05 2018 20:52
hi guys, i have a project that is coming up that could specify nodejs, body-parser and vanillajs as the stack of choice. i want to know if it is even possible to grok the backend and middle-ware with the first two.
Brad
@bradtaniguchi
Nov 05 2018 21:04
@Giveback007 hehe yes :P
@jeffersonnnn what? I'm confused as to what your talking about, nodejs is a JS runtime, body-parser is a node package, and I guess your saying "no express" for vanillajs?
And isn't body-parser a middleware for express anyways?
Jefferson
@jeffersonnnn
Nov 05 2018 21:06
@bradtaniguchi to be fair, i don't quite understand it either haha. but that exactly is what i am saying. no express.
is it possible to work with node and body parser without needing express?
Brad
@bradtaniguchi
Nov 05 2018 21:08
@jeffersonnnn Idk about body-parser, but node is what express runs on.
I suggest you go out and make sure you understand what node is, before anything else, so you can get a better grasp on how each of the things you just talked about relates
Jefferson
@jeffersonnnn
Nov 05 2018 21:09
i know a fair bit of node infact.
Brad
@bradtaniguchi
Nov 05 2018 21:10
So then you should know you don't need express to make a web-server on node
Jefferson
@jeffersonnnn
Nov 05 2018 21:10
with this new project, we are experimenting with using no framworks aside node, hence my weird question haha
Brad
@bradtaniguchi
Nov 05 2018 21:11
node isn't a framework, its a run-time. It's like calling the java virtual machine a framework (if your familiar with java)
Jefferson
@jeffersonnnn
Nov 05 2018 21:12
@bradtaniguchi yes yes. i know body-parser is standalone, but i just wonder if it can stand without express.
Brad
@bradtaniguchi
Nov 05 2018 21:13
I don't think so, but if your creating your own web server, then why not making your own body parser?
AFAIK body-parser used to be built into express, but now it's it's own package, I dont' know the reasoning exactly, but I've never heard of it being "stand alone"
Jefferson
@jeffersonnnn
Nov 05 2018 21:16
@bradtaniguchi valid points. Ah, okay then. I guess i'll have to just wait and see. Thanks bro
Brad
@bradtaniguchi
Nov 05 2018 21:16
np goodluck :D
Jason Luboff
@JLuboff
Nov 05 2018 21:23
@Giveback007 Hey man, doing alright how about yourself?
@jeffersonnnn As @bradtaniguchi mentioned,body-parser is meant to work in conjunction with express. I did a quick search and found this though which maybe of some help https://itnext.io/how-to-handle-the-post-request-body-in-node-js-without-using-a-framework-cd2038b93190
Jefferson
@jeffersonnnn
Nov 05 2018 21:31
@JLuboff that link looks like exactly what i need to get started on this path. Perfect. Thank you too !
Jason Luboff
@JLuboff
Nov 05 2018 21:32
:thumbsup: