Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the Node.js expansion module Hashish

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report