Get the App
SLTechnology News&Howtos  ›  Development  › 

How to understand the Node.js expansion module Hashish

Shulou Source: shulou.com Published: 2022-06-02 14:11:45 10月15日 Update

In this issue, the editor will bring you about how to understand the Node.js expansion module Hashish. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Introduce you to the Node.js extension module, Hashish. Hashish is a Hash assembly sublibrary of JavaScript, in other words, it contains a series of data structure manipulation functions.

For example:

Var Hash = require ('hashish'); Hash ({a: 1, b: 2, c: 3, d: 4}) .map (function (x) {return x * 10}) .filter (function (x) {return x)

< 30 }) .forEach(function (x, key) { console.log(key + ' =>

'+ x);})

The Hash construction here is {a: 1, b: 2, c: 3, d: 4}; next, map a function, each Hash value multiplied by 10, then Hash evolves to {a: 10, b: 20, c: 30, d: 40}; then filter out values less than 30, where Hash is {a: 10, b: 20}, * *, forEach will operate on each practical value, and the output value is:

A = > 10 b = > 20

Please note that here Hash can manipulate each node, and all the combinations can be put together to keep your code *.

If you can't or don't want to use the connection function, hashish can also be attached to Hash in the form of each link. In the form of:

Var Hash = require ('hashish'); var obj = {a: 1, b: 2, c: 3, d: 4}; var mapped = Hash.map (obj, function (x) {return x * 10}); console.dir (mapped)

Note that the code on obj hash is called Hash.map. Multiply the output value of Hash by 10:

{a: 10, b: 20, c: 30, d: 40}

Hashish can also provide various properties of the interface and functions in the Hash.xxx link. For example:

$node > var Hash = require ('hashish'); > var obj = {a: 1, b: 2, c: 3, d: 4}; > > Hash (obj). Keys [' a', 'baked,' c','d'] > Hash (obj). Values [1, 2, 3, 4] > Hash (obj). Length 4

Of course, you can install hashish through npm:

Npm install hashish above is the editor for you to share how to understand the Node.js extension module Hashish, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Module function code content form link analysis combination output practical next professional small and medium rich in content function can be passed that is attributes in other words data Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology MariaDB Apple Redmi