Node.js Core Modules 核心模组 The modules do need to use NPM install

7 篇文章 0 订阅

The modules do need to use NPM install:

These modules installed locally  with you install NODE js 

1. Path module

LOAD:

var path = require("path")

Using:

path.basename(__filename)  # pluck out the file name from the path

path.join(*args)  join a series of path name with "/"

 

2. Utilie module

var util = require("util)

util.log()  have a same result as console.log(), but it has log the time of the code loading time staple 

//++++++++++++++

util.inherits(object1, ob2)

help ob1 to inherits all of function in ob2

 

3. V8

Get current memory

var v8 = require("v8")

util.log(v8.getHeapStatistics())

=========================================================================

4. Reading module

ask question to user in termial and saving those answers 

var readline = require('readline')

var rl = readline.createInterface(process.stdin, process.stout)

# readline helps us to control thoes object 

rl.question(string, function(answer))

# ask question

# handle the answer

rl.setPrompt('');

in the question() function to repeat the question prompt

 

5. EventEmitter

require('events');

var emitter = new events.EventEmitter();

emitter.on('customEvent', function(string));

emitter.emit('customEvent', string1)

emit will push the second argument into customEvent and run it! \

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值