📜 ⬆️ ⬇️

News from the world of Node: DataCollection.js, Supererror, Readability

DataCollection.js


DataCollection.js * - is a library for querying the data source. You can use it both in the browser and on the Node side. The example in the documentation uses an array of objects, on which selection (filtering) operations are performed using a key / value representation, as well as some sql operators are used, such as max and distinct .

The authors declare that this product is fast, despite the fact that I can not confirm this fact. Although the library includes features such as creating indexes for certain keys. DataCollection.js is a well-documented project and has a test coverage of 95.5% .

Creature:
 var characters = [ { id: 1, first_name: 'Jon', last_name: 'Snow', gender: 'm', age: 14, location: 'Winterfell' } // ....... , ]; var charDC = new DataCollection(characters); 

Application:
 // Will return Jon, Eddard and Ramsay charDC.query() .filter({gender: 'm', age__lt: 40}) .values(); // Updates location charDC.query() .filter({location: 'Winterfell'}) .exclude({first_name: 'Jon'}) .update({location: 'King\'s Landing'}); 


Supererror


You probably had to work on projects in which you recorded (registered) errors using the console.error instruction. Most likely in such situations you would like to get more useful information (for example, the line number) without changing the source code. If this is your case, then the supererror ** project will probably be of interest to you .
')
This project changes console.error by adding highlighting, line number, and call stacks for the Error object.

Using:
 require('supererror'); console.error('Some', new Error('transient error'), 'happened using', { some: 'value' }); console.error(); // no info added console.error('Using %d as a %s.', 42, 'number'); 

Result:
image

Readability


The Readability *** project changes the format of a web page to a simplified HTML Arc90 version. For this, jsdom is used. Also, this product supports a large number of encodings such as GB2312 , and also readability supports relative URLs, thanks to which images continue to be displayed.

I seem to recall the problems with the encoding and relative addresses of images in other branches of the Readability project, so the above statement looks good.

Marks


* (GitHub: thestorefront / DataCollection.js , License: MIT, npm: data-collection ) from Storefront.
** (GitHub: nebulade / supererror , License: MIT, npm: supererror ) by Johannes Zellner.
*** (GitHub: luin / node-readability , License: Apache 2.0, npm: node-readability ) by Zihua Li

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


All Articles