Skip to content
Advertisement

Tag: node.js

How to generate unique ID with node.js

How to set a variable value with database query callback? How I can do it? Answer It’s been some time since I used node.js, but I think I might be able to help. Firstly, in node, you only have a single thread and are supposed to use callbacks. What will happen with your code, is that base.getID query will get

NodeJS: Would App Run Faster if Freeze Objects?

Most of my objects/functions do not change. Would the application run faster if I freeze most of the objects via Object.freeze(object)? Or will it make no difference at all? Answer Freezing (and sealing) causes a signficant performance hit instead of a gain across various browsers. Just take a look at some of the jsperf benchmarks. EDIT: Here’s the relevant issue

Unable to run node app.js file

I am learning node.js and I am trying to run the app.js file using the command node app.js but the bash returns nothing (no errors either). Here are the steps I followed: $ brew install node $ sudo npm install -g express $ sudo npm install -g express-generator after i get into a new folder I created I run $

What does it mean by “message queue” in this link?

I was trying to understand what’s an event loop in JavaScript. Came across Mozilla Developer Network’s link about event loop. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/EventLoop It mentions Queue A JavaScript runtime contains a message queue, which is a list of messages to be processed. To each message is associated a function. When the stack is empty, a message is taken out of the queue

How to add rooms in Node.js with Socket.io?

I have been following up many articles to learn making chat application with Node.js and Socket.io. Everything is clear and I can make an application moving messages from client to server and emitting to all etc but only one thing is not clearing and cannot figure this out. How can I add rooms to io.sockets.manager.room? What is the code to

How to create a simple http proxy in node.js?

I’m trying to create a proxy server to pass HTTP GET requests from a client to a third party website (say google). My proxy just needs to mirror incoming requests to their corresponding path on the target site, so if my client’s requested url is: The following resource should be served: Here is what I came up with: It works

Advertisement