📜 ⬆️ ⬇️

News from the world of Node: Node 0.11.14, svgexport, node-webkitgtk, Nightmare, Prototypes, node-libpq and node-pg-native

Node 0.11.14


libuv
I saw Light Node 0.11.14 , carrying updates for uv , http_parser , npm , openssl , and v8 .

It seems that this update contains fixes for almost all modules: cluster rolled back to version 0.10 ( setupMaster behavior), console.dir accepts options, events are capable of displaying / returning other events that have the ability to flow (event that is leaking). In short, we have a lot of changes you need to know about before upgrading.

The uv version included in 0.11.14, is rc1. Also, when I visited the uv repository to check out the latest commits, I noticed a cool logo with a unicornorex (dinosaur unicorn).

svgexport


Ali Shakiba svgexport (GitHub: shakiba / svgexport , npm: svgexport ) command line utility for converting SVG files to PNG, JPEG, and PDF.
')
The utility is based on PhantomJS and the author used it to automatically convert icons for iOS and Android projects. This is similar to the cool use of Node / Gulp / Grunt as part of a non-web-native chain of assemblies, which I had never suspected.

node-webkitgtk


The node-webkitgtk (GitHub: kapouer / node-webkitgtk , License: MIT , npm: webkitgtk ) from Jérémy Lal is a collection of webkitgtk backlinks for Node. The product's software interface can be called chained, so you can do something like this:

 WebKit().load('http://github.com').png('github.png').pdf('github.pdf') 

This product is designed to be used without problems, so it can be useful for such things as generating thumbnails for websites or for integration testing, but I have not tried it.

Nightmare


image

By far the most fragile and confusing part of testing is the full stack integration testing. I used a bunch of different approaches based on PhantomJS or Selenium , but they all always caused difficulties.

One of the most common problems lies in the interaction interfaces (API) - PhantomJS itself has a strange API, especially if you are accustomed to the standard development of Node-applications. That is why I was delighted to hear about Nightmare (GitHub: segmentio / nightmare , license: MIT , npm: nightmare ), the purpose of which is to simplify the software interface of interaction with PhantomJS .

If you want to try out Nightmare in action, be careful, you will need to install PhantomJS on your system. This can be done using Homebrew on Macs, and here (on the main project site) you can find packages for other platforms.

Nightmare has a chained programming interface (API) that allows you to run JavaScript over the DOM on the target page. If, for example, you have a page with jQuery loaded, then you can access $ in the evaluate function during the callback.

Here I downloaded the web application that starts the server (in app.js ), then I filled in the input form and sent it to the server. The code in the evaluate function will be executed on the page, so that I can use jQuery to work with DOM.

 var server = require('./app'); var Nightmare = require('nightmare'); new Nightmare() .goto('http://localhost:3000') .type('input[name="email"]', 'alex@example.com') .type('input[name="password"]', 'password') .click('.sign-in') .evaluate(function() { return $('.sign-out').is(':visible'); }, function(visible) { assert(visible, '.sign-out should be visible'); }) .run(function() { server.close(); }); 

Naturally, you can use this product for general tasks for which you would use PhantomJS , but I think it could be cool enough to use Nightmare to test complex code on the client side.

Prototypes


Alex Fernández presented prototypes (GitHub: alexfernandez / prototypes , under the license: MIT , npm: prototypes ). This module modifies prototype objects, so use it carefully, but you can also find some useful methods.

Here is an example of use:

 'pepitus'.startsWith('pep'); 'hi.there'.substringFrom('.'); // 'there' { a: 1, b: 2 }.forEach(function(value, key) { console.log(key, value); }); 

node-libpq and node-pg-native


node-libpq (GitHub: brianc / node-libpq , license: MIT , npm: libpq ) from Brian M. Carlson is a collection of native bindings of the libpq client C library for PostgreSQL.

The goal of this module is to reflect as closely as possible the C program interface presented by libpq and provide an absolutely minimal level of abstraction. This product is designed to be extremely low-level and give the user the same access to libpq as it is possible to get directly from C, except for node.js! Since you have to pay for everything, the fee for “proximity to hardware” is the need to use a JavaScript interface similar in style to C in JavaScript.

Brian is the author of the popular PostgreSQL library - pg , and he also recently released node-pg-native , which is a high-performance PostgreSQL module using node-libpq .

Sean Levy introduced us to node-pg-native because he is crazy about the synchronous software interface:

 var rows = client.querySync('SELECT NOW() AS the_date') console.log(rows[0].the_date) //Tue Sep 16 2014 23:42:39 GMT-0400 (EDT) 

It's really that simple!

From translator


Here is a translation of two articles by Alex Yungi Jung, tyts and tyts .

For some time I decided to go into the field of open source software development, so if someone wants to intercept the relay of Alex's review translations, I’m probably the community as a whole will be happy to see these transfers.

Thank you all for your attention.

Source: https://habr.com/ru/post/239927/


All Articles