node.js-v0.8API解读(3)- api的新增部分

2012-07-03 01:20

node.js-v0.8API解读(3)- api的新增部分

by snoopyxdy

at 2012-07-02 17:20:40

original http://snoopyxdy.blog.163.com/blog/static/601174402012624741647

以下是常用node.js-v0.8的新增API:

1、child_process
silent option to child_process.fork() - stdout and stderr won't be shared with parent.
//在child_process.fork()方法可以设置silent配置,这样子进程的就不会进行stdout输出到屏幕了

.disconnect() when using child_process.fork() this will allow the child to die gracefully.
//执行此方法,将会把  child_process.fork() 执行的子进程优雅的退出

stdio option for child_process.spawn() - configuration of child's stdio (file descriptors).
//可以对child_process.spawn()方法做stdio的设置,具体设置见DOC

detached option for child_process.spawn() - make the child a process group leader (see docs)
//detached分离子进程,这样子进程就将从node的parent进程中的event loop中剥离,见DOC

child.send() can now send net.Server and net.Socket as second argument.
//看了官方文档的事例,表示child.send()可以讲server或者socket对象传递给子进程,这样可以在子进程做响应处理了。

2、fs
fs.appendFile() and fs.appendFileSync().
//往文件的最后增加内容,相见api

wx, wx+, ax, and ax+ modes to fs.open() and fs.openSync().
//新增以上这些模式打开文件,x表示 exclusive mode 独家模式,其他进程无法访问这个文件了

3、http
callback optional argument to server.close().
//为server.close()方法新增了一个可选的回调函数

sendDate property to http.ServerResponse.
//为 http.ServerResponse 类添加一个sendDate属性
//当设置response.sendDate 为 ture 时,将会在响应头上加入,默认是true
//Date:
Mon, 02 Jul 2012 08:59:35 GMT

http.request() and http.get() can accept as their argument a url that is parsed with url.parse()
//这2个方法可以接受url.parse()生产的对象作为参数

4、https
ciphers, rejectUnauthorized option to https.request() and https.get().
//新增以上2个配置,详细见DOC

5、net
net.connect(options, [connectionListener]).
//在创建connect套接字时就将 connect事件的监听函数作为第二个参数传入

callback optional argument to server.close().
//添加一个可选的回调函数

server.listen({ fd: someNumber }) to listen on arbitrary file descriptors.
//传入任意的文件描述符,这些文件描述符假定都绑定到了 一个端口或者域名套接字

6、process
process.abort().
//退出进程,并且产生一个核心文件,不大明白

process.hrtime(), hi-res timer with up to nanosecond granularity.
//返回纳秒时间

7、querystring
querystring.parse(str, [sep], [eq], [options]).
//新增一个处理字符串的方法,可以用来替换分割等等,详见API