近期node社区一直在在热火朝天的完善libuv中.
新功能开发方面的似乎变动不大.
从目前的使用来看,在osx下稳定性还不错.可用度也很高
窃以为, 已经可以作为开发环境来了.
btw.前几天出了个missing headers files的编译问题
这里把v0.5引入的新功能做了各简单的汇总.
Buffer
二进制数值读写
- buffer.readUInt8(offset, endian)
- buffer.readUInt16(offset, endian)
- buffer.readUInt32(offset, endian)
- buffer.readInt8(offset, endian)
- buffer.readInt16(offset, endian)
- buffer.readInt32(offset, endian)
- buffer.readFloat(offset, endian)
- buffer.readDouble(offset, endian)
- buffer.writeUInt8(value, offset, endian)
- buffer.writeUInt16(value, offset, endian)
- buffer.writeUInt32(value, offset, endian)
- buffer.writeInt8(value, offset, endian)
- buffer.writeInt16(value, offset, endian)
- buffer.writeInt32(value, offset, endian)
- buffer.writeFloat(value, offset, endian)
- buffer.writeDouble(value, offset, endian)
buffer填充
- buffer.fill(value, offset=0, length=-1)
Child Process
child_process.fork
主进程与子进程简单通信
// master.js
var cp = require(‘child_process’);
var n = cp.fork(__dirname + ‘/child.js’);
n.on('message’, function(m) {
console.log('PARENT got message:’, m);
});
n.send({ hello: ‘world’ });
// child.js
process.on('message’, function(m) {
console.log('CHILD got message:’, m);
});
process.send({ foo: ‘bar’ });
File System
chown支持
- fs.chown(path, mode, [callback])
- fs.chownSync(path, mode)
- fs.fchown(path, mode, [callback])
- fs.fchownSync(path, mode)
- fs.lchown(path, mode, [callback])
- fs.lchownSync(path, mode)
timestamp修改
- fs.utimes(path, atime, mtime, callback)
- fs.utimesSync(path, atime, mtime)
- fs.futimes(path, atime, mtime, callback)
- fs.futimesSync(path, atime, mtime)
fsync支持
- fs.fsync(fd, callback)
- fs.fsyncSync(fd)
file.writeStream
file.bytesWritten
Http
http.request与http.getAgent支持unix domain socket
OS
- os.platform()
- os.arch()
- os.release()
- os.getNetworkInterfaces()
process
- process.arch
- process.uptime()
其他
新增对module cache的访问 require.cache
新增对主module的访问 require.main
新增异步模快定义的支持
define(function (require, exports, module) {
var PI = Math.PI;
exports.area = function ® {
return PI * r * r;
};
exports.circumference = function ® {
return 2 * PI * r;
};
});