Your Choice JavaScript News

Node News Tuesday, January 30

Node News TLDR / Table of Contents

Score: 1605000
URL: https://medium.com/the-node-js-collection/modern-javascript-explained-for-dinosaurs-f695e9747b70
Tweeted At: Mon Jan 29 13:24:02 +0000 2018
Publish Date: 2017-10-18T17:25:08.708000+00:00
Author: Peter Jang

  • With the defaults the contents of package.json should look something like:{ “name”: “your-project-name”, “version”: “1.0.0”, “description”: “”, “main”: “index.js”, “scripts”: { “test”: “echo \”Error: no test specified\” exit 1″ }, “author”: “”, “license”: “ISC”}To install the moment.js JavaScript package, we can now follow the npm instructions from their home page…
  • { “name”: “modern-javascript-example”, “version”: “1.0.0”, “description”: “”, “main”: “index.js”, “scripts”: { “test”: “echo \”Error: no test specified\” exit 1″ }, “author”: “”, “license”: “ISC”, “dependencies”: { “moment”: “^2.19.1” }}This is useful later when sharing a project with others — instead of sharing the node_modules folder (which can get very large), you only…
  • So for the longest time, organizing JavaScript code in multiple files required you to load each file with variables shared globally.This is actually what we’re doing with the above moment.js example — the entire moment.min.js file is loaded in the HTML, which defines a global variable moment, which is then available to…
  • Instead of loading all of moment.min.js with an HTML script tag, you can load it directly in the JavaScript file as follows:// index.jsvar moment = from this is how module loading works in node.js, which works great since node.js is a server side language with access to the computer’s file…
  • A JavaScript module bundler is a tool that gets around the problem with a build step (which has access to the file system) to create a final output that is browser compatible (which doesn’t need access to the file system).

Tags: JavaScript, command line, file, script src=, package manager

Score: 175500
URL: https://codeburst.io/a-guide-to-automating-scraping-the-web-with-javascript-chrome-puppeteer-node-js-b18efb9e9921?gi=a245f024ac2b
Tweeted At: Mon Jan 29 16:00:01 +0000 2018
Publish Date: 2017-10-25T13:03:11.143000+00:00
Author: Brandon Morelli

  • The code we’ll walkthrough will take a screenshot of any website you tell it to.To start out, create a file named test.js and copy in the below code:Let’s walk through this example line by line.Line 1: We require our Puppeteer dependency that we installed earlierLine 3–10: This is our main…
  • Because we’ve also used the await keyword, the function will pause here until our Promise resolves (until we either successfully created our instance of Chrome, or errored out)const page = await browser.newPage();Here we create a new page in our automated browser.
  • We can change the size of our page by adding in this line of code:await page.setViewport({width: 1000, height: 500})Which results in this much nicer looking screenshot:Here’s what our final code for this example looks like:Example #2 — Lets Scrape some DataNow that you know the basics of how Headless Chrome and Puppeteer Work,…
  • As you’ll see, there’s a TON of different methods we can use to not only click around on a website, but also to fill out forms, type things, and read data.In this tutorial we’re going to scrape Books To Scrape, which is a fake bookstore specifically setup to help people…
  • Here’s what it looks like when it’s all put together:const result = await page.evaluate(() = { let title = let price = { title, price}});The only thing left to do is return our result so it can be logged to the console:return result;Here’s what your final code should look like:You…

Tags: code, Headless Chrome, node, scrape, Best Online Node

Score: 130500
URL: http://www.c-sharpcorner.com/article/sql-server-crud-actions-using-node-js/
Tweeted At: Mon Jan 29 08:00:01 +0000 2018
Publish Date:
Author: Sibeesh Venu

  • Creating Node JS Application In Visual Studio – – – – You can find an option as Node JS in your “Add New Project” window, as shown below.
  • Select all the data from database using Node JS – – – – Now, run your application and see the output.
  • Insert data to database using Node JS – – – – We can always perform some insert query too using Node JS, the difference will be – as we have Transactions in SQL , we will include that too here.
  • Delete data from database using Node JS – – – – As we performed insert operation, we can do the same for delete operation as well.
  • Update data from database using Node JS – – – – The only action pending here to perform is UPDATE.

Tags: Node JS, node js application, Node JS tool, Node JS Applications, Node JS code

Score: 100000
URL: http://www.matridtech.net/blog/why-should-you-choose-node-js-over-other-technologies/
Tweeted At: Mon Jan 29 14:28:51 +0000 2018
Publish Date:
Author: Vivek Kumar

  • Node.js is a server side platform built on Google Chrome’s JavaScript Engine or poularly known as the V8 engine.
  • If you plan to build a real-time or data streaming web application, Node.js is definitely the perfect solution for you to use.Node.js is highly efficient and much easier to develop.
  • Node.js apps are easily compatible with Database Queries – – The queries for MongoDB and NoSQL databases, that are essential for today’s enterprises  , are written in JavaScript.
  • Since JavaScript is also the programming language of Node.js, developers don’t need any complex processes or techniques when combining Node.js and NoSQL databases.
  • Node.js is best for building Real-time Web Apps – – The event-driven architecture of node.js makes it a shrewd choice for real-time applications, especially chat applications and games.

Tags: node.js, node.js apps, open source, web frontend development, dynamic web apps

Score: 40000
URL: https://blogs.msdn.microsoft.com/nilayshah/2018/01/29/vsts-ci-to-build-and-test-node-js-app-with-gulp-and-mocha/
Tweeted At: Tue Jan 30 07:21:05 +0000 2018
Publish Date: 2018-01-29T10:11:27+00:00
Author: Nilay Shah

  • In this post, we will see how to configure Visual Studio Team Services (VSTS) Continuous Integration (CI) Build for Node.js application.
  • This post is extension of my previous post, where I’ve covered Unit testing node application with TypeScript in VS Code  —  using mocha, chai, mochawesome, gulp, travis – – If you are looking for setting up node project with TypeScript, Gulp and Mocha, first refer previous post and then continue below…
  • In below post, we’ll import existing project from Github to VSTS and then configure VSTS CI build using web only steps.
  • If you are already using VSTS for your team project, directly start from step 3 below.
  • Please share your thoughts using comments on this post.

Tags: configure VSTS CI, Unit testing node, Visual Studio Team, refer previous post, single Phase i.e

Score: 35100
URL: https://www.nearform.com/blog/introducing-node-clinic-a-performance-toolkit-for-node-js-developers/
Tweeted At: Mon Jan 29 09:27:01 +0000 2018
Publish Date:
Author: Conor O’Neill

  • We’re really happy to announce the open source Node Clinic toolkit and Clinic Doctor tool.
  • In a nutshell, Clinic simplifies the process of investigating and fixing performance issues in your Node.js applications.
  • Symptoms such as low cpu usage, blocking garbage collection, frequent event loop delay or chaotic number of active handles may indicate a number of potential problems.
  • (Note you might hit some issues if you pick an old version of those release lines) – – nearForm has a long history working on performance in Node.js apps and our own David Mark Clements created the 0x tool many moons before we kicked off Node Clinic.
  • 0x helps profile your application with the use of flamegraphs and is one of the tools that Doctor will recommend in certain situations.

Tags: event loop, event loop delay, performance issues, Doctor, Clinic Doctor tool

Score: 22500
URL: https://www.sitepoint.com/debugging-javascript-node-debugger/
Tweeted At: Mon Jan 29 08:17:01 +0000 2018
Publish Date: 2018-01-15T09:00:17+00:00
Author:

  • Here are a few commands I find you must memorize: – sb(‘myScript.js’, 1) set a breakpoint on first line of your script – c continue the paused process until you hit a breakpoint – repl open the debugger’s Read-Eval-Print-Loop (REPL) for evaluation – Don’t Mind the Entry Point – When…
  • Say you want to debug the following program: – function getAllDucks() { – var ducks = { types: [ – { – name: ‘Dabbler’, – attributes: [ – { inSeaWater: false }, – { canDive: false } – ] – }, – { – name: ‘Eider’, – attributes: [ -…
  • For example: – var dabbler = { – name: ‘Dabbler’, – attributes: [ – { inSeaWater: false }, – { canDive: false } – ] – }; – – // … – – var ducks = { types: [ – dabbler, – // … – ] }; – – Client-Side…
  • A Node program can use the code above, for example: – var assert = require(‘assert’); – var DuckImageView = event = { currentTarget: { } }; – – var view = new element = ‘fadeOut’, ‘Add fadeOut class in element’); – – As long as your JavaScript is not tightly…
  • This allows you configure the debugging entry point, for example: – { – “type”: “node”, – “request”: “launch”, – “name”: “JavaScript Tests”, – “program”: // Point this to the same folder as the entry point – “cwd”: “${workspaceRoot}” – } – – At a high level, you tell VS Code…

Tags: Node debugger, code, debugging session, Node debugger command, command line

Score: 18000
URL: https://www.infoworld.com/article/3250630/web-development/traffic-shaping-websockets-using-nodejs-and-redis.html
Tweeted At: Sun Jan 28 18:30:19 +0000 2018
Publish Date: 2018-01-24T00:00:00+00:00
Author: technologists

  • Even in the so-called modern web application, AJAX HTTP requests fly back and forth between the client and server layers, moving data in both directions.
  • In this article, we’ll explore the problem of managing requests and responses in the context of full-duplex communication (WebSockets), and illustrate how to cope with it using an example application built with Node.js and Redis.
  • Your previous architecture wasn’t as quick and had built-in limits that slowed things significantly as you approached the pricing request service limits, but by employing WebSockets, you’ve reduced the HTTP header overhead and network latencies while improving overall speed.
  • The request to the pricing server would not be made until after the delay, and if calculated correctly, would prevent an onslaught of traffic killing the pricing service.
  • To calculate the delay in sending the request to the pricing server in our example, we’ll use a singular variable: the number of delays not yet resolved.

Tags: requests, delay, traffic, HTTP requests, external request/response service

Score: 15000
URL: https://airbrake.io/blog/nodejs-error-handling/err_buffer_out_of_bounds
Tweeted At: Tue Jan 30 00:00:37 +0000 2018
Publish Date: 2018-01-29T16:00:21+00:00
Author: Andrew Powell-Morse

  • We’ll also explore the basic process of using in Node.js, which will illustrate how passing invalid bounds arguments (offsets or lengths, in particular) to some class methods can throw errors.
  • // logging module – index.js const fs = require(“fs”); const SeparatorCharacterDefault = ‘-‘; const SeparatorLengthDefault = 40; module.exports = { /** * Outputs a line separator via console.log, with optional first argument text centered in the middle.
  • */ logSync: function (value) { if (value instanceof Error) { logError(value, arguments[1], true); } else { logValue(value, true); } } }; /** * Outputs a line separator via console.log.
  • if (synchronous) { fs.writeSync(1, value + ‘ – – ‘); } else { console.log(value); } }    * Outputs a line separator via console.log, with optional first argument text centered in the middle.
  • Similarly, let’s try passing an in-bounds with an invalid argument: – – Once again, this throws an , this time with the indication that is outside the buffer bounds: – – If we dig into the Node.js class source code we can quickly find exactly where these errors originate from….

Tags: param, param char Separator, param length Total, length Total separator, Total separator length

Score: 13000
URL: https://medium.com/the-node-js-collection/modernizing-node-js-with-idiomatic-javascript-f18d984dcf93
Tweeted At: Tue Jan 30 06:05:05 +0000 2018
Publish Date: 2018-01-29T17:07:09.090000+00:00
Author: Node.js Foundation

  • In other words, if developers want to improve the performance of their JavaScript, what sort of code should they write?In the past, performance advice was often presented as anti-patterns, for example “Don’t use for-each” or “Don’t use try-catch”.
  • For much of its life, Node.js embedded the V8 engine as the only option to run JavaScript code.
  • Fast-forward to 2018 — Node.js can now also be powered by the ChakraCore JavaScript engine and V8 has a new optimizing compiler Turbofan, both of which have a very different performance profile to Crankshaft.
  • The answer is straightforward: JavaScript developers should focus on writing idiomatic, readable and maintainable code and not focus on the compilers underneath.
  • Ideally, developers should not have to worry about any of those micro-optimizations, instead they should be able to write something much simpler like the following, and trust that the compiler will do the right thing for performance:We believe that instead of developers specializing their JavaScript code for the compilers, compiler…

Tags: JavaScript, developers, code, JavaScript virtual machines, performance

Score: 11950
URL: https://hackernoon.com/building-a-serverless-rest-api-with-node-js-and-mongodb-2e0ed0638f47?gi=31f5acc5c85f
Tweeted At: Thu Jan 25 17:33:01 +0000 2018
Publish Date: 2018-01-02T16:24:25.986000+00:00
Author: Adnan Rahić

  • You just give your app a connection URL and there’s the database, ready to go.You up for a challenge?This article will show you how to hook up a MongoDB database as a service to a Serverless REST API.
  • This is when we want to initialize the database connection, the first time the function is invoked, when the Docker container is first initialized.
  • Every subsequent request to the Lambda function should use the existing database connection.
  • $ sls create -t aws-nodejs -p rest-api cd rest-apiThis command will scaffold out all the necessary files and code to create our Lambda functions and API Gateway events.
  • AWS Lambda will freeze the process, any state data and the events in the Node.js event loop (any remaining events in the event loop processed when the Lambda function is called next and if AWS Lambda chooses to use the frozen process).

Tags: Serverless, database connection, Serverless REST API, Serverless Architecture, Serverless framework

Score: 1350
URL: https://github.com/cozmo/jsQR
Tweeted At: Mon Jan 29 23:57:03 +0000 2018
Publish Date:
Author: cozmo

  • A pure javascript QR code reading library.
  • This library takes in raw images and will locate, extract and parse any QR code found within.
  • In general changes should hope to increase the number of images that read.
  • However due to the nature of computer vision some changes may cause images that pass to start to fail and visa versa.
  • These outcomes can be evaluated in the context of a PR to determine if a change improves or harms the overall ability of the library to read QR codes.

Tags: pure javascript QR, javascript QR code, window line endings, QR code reading, code reading library

Score: 600
URL: https://www.producthunt.com/posts/expresscart
Tweeted At: Mon Jan 29 12:01:24 +0000 2018
Publish Date: 2018-01-28T08:00:00+00:00
Author:

  • expressCart is an open source, fully functional Node.js shopping cart with Stripe and PayPal payment options built in by default.
  • expressCart is a searched based shopping cart, meaning it doesn’t have categories but rather indexes products by keywords and title.

Tags: PayPal payment options, Node.js shopping cart, searched based shopping, indexes products, open source

Score: 580
URL: https://www.youtube.com/watch?a&feature=youtu.be&v=SSDED3XKz-0
Tweeted At: Mon Jan 29 18:39:08 +0000 2018
Publish Date:
Author:

    Tags: upload original content, YouTube, videos, music, friends

    The Complete Node.js Developer Course (2nd Edition) (60,232 students enrolled)

    By Andrew Mead
    • Build, test, and launch Node apps
    • Create Express web servers and APIs
    • Store data with Mongoose and MongoDB
    • Use cutting-edge ES6/ES7 JavaScript
    • Deploy your Node apps to production
    • Create real-time web apps with SocketIO

    Learn more.


    Angular (Angular 2+) & NodeJS - The MEAN Stack Guide (26,806 students enrolled)

    By Maximilian Schwarzmüller
    • Build real Angular + NodeJS applications
    • Understand how Angular works and how it interacts with Backends
    • Connect any Angular Frontend with a NodeJS Backend
    • Use MongoDB with Mongoose to interact with Data on the Backend
    • Use ExpressJS as a NodeJS Framework
    • Provide a great user experience by using Optimistic Updating on the Frontend
    • Improve any Angular (+ NodeJS) application by adding Error Handling

    Learn more.


    Comments are closed, but trackbacks and pingbacks are open.