您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > nodejs手册中文版
Node.jsManual&Documentation项目网址:发布:LenzhangTableOfContentsSynopsis概要GlobalObjects全局对象oglobaloprocessorequire()orequire.resolve()orequire.pathso__filenameo__dirnameomoduleTimers定时器osetTimeout(callback,delay,[arg],[...])oclearTimeout(timeoutId)osetInterval(callback,delay,[arg],[...])oclearInterval(intervalId)Modules模块oCoreModules核心模块oFileModules文件模块oLoadingfrom`node_modules`Folders从`node_modules`目录中加载Optimizationstothe`node_modules`LookupProcess优化`node_modules`的查找过程oFoldersasModules目录作为模块oCaching缓存oAllTogether...总结一下...oLoadingfromthe`require.paths`Folders从`require.paths`目录中加载Note:**PleaseAvoidModifying`require.paths`**注意:**请不要修改`requires.paths`Setting`require.paths`tosomeothervaluedoesnothing.将`require.paths`设为其他值不会产生任何作用Puttingrelativepathsin`require.paths`is...weird.不建议在`require.paths`中发入相对路径ZeroIsolation零隔离Addenda:PackageManagerTips附录:包管理技巧Addons扩展插件process进程oEvent:'exit'事件:'exit'oEvent:'uncaughtException'事件:'uncaughtException'oSignalEvents信号事件oprocess.stdoutoprocess.stderroprocess.stdinoprocess.argvoprocess.execPathoprocess.chdir(directory)oprocess.cwd()oprocess.envoprocess.exit(code=0)oprocess.getgid()oprocess.setgid(id)oprocess.getuid()oprocess.setuid(id)oprocess.versionoprocess.installPrefixoprocess.kill(pid,signal='SIGTERM')oprocess.pidoprocess.titleoprocess.platformoprocess.memoryUsage()oprocess.nextTick(callback)oprocess.umask([mask])util工具模块outil.debug(string)outil.log(string)outil.inspect(object,showHidden=false,depth=2)outil.pump(readableStream,writableStream,[callback])outil.inherits(constructor,superConstructor)Events事件模块oevents.EventEmitteremitter.addListener(event,listener)emitter.on(event,listener)emitter.once(event,listener)emitter.removeListener(event,listener)emitter.removeAllListeners(event)emitter.setMaxListeners(n)emitter.listeners(event)emitter.emit(event,[arg1],[arg2],[...])Event:'newListener'事件:'newListener'Buffers缓冲器onewBuffer(size)onewBuffer(array)onewBuffer(str,encoding='utf8')obuffer.write(string,offset=0,encoding='utf8')obuffer.toString(encoding,start=0,end=buffer.length)obuffer[index]oBuffer.isBuffer(obj)oBuffer.byteLength(string,encoding='utf8')obuffer.lengthobuffer.copy(targetBuffer,targetStart=0,sourceStart=0,sourceEnd=buffer.length)obuffer.slice(start,end=buffer.length)Streams流ReadableStream可读流oEvent:'data'事件:'data'oEvent:'end'事件:'end'oEvent:'error'事件:'error'oEvent:'close'事件:'close'oEvent:'fd'事件:'fd'ostream.readableostream.setEncoding(encoding)ostream.pause()ostream.resume()ostream.destroy()ostream.destroySoon()ostream.pipe(destination,[options])WritableStream可写流oEvent:'drain'事件:'drain'oEvent:'error'事件:'error'oEvent:'close'事件:'close'oEvent:'pipe'事件:'pipe'ostream.writableostream.write(string,encoding='utf8',[fd])ostream.write(buffer)ostream.end()ostream.end(string,encoding)ostream.end(buffer)ostream.destroy()Crypto加密模块ocrypto.createCredentials(details)ocrypto.createHash(algorithm)ohash.update(data)ohash.digest(encoding='binary')ocrypto.createHmac(algorithm,key)ohmac.update(data)ohmac.digest(encoding='binary')ocrypto.createCipher(algorithm,key)ocipher.update(data,input_encoding='binary',output_encoding='binary')ocipher.final(output_encoding='binary')ocrypto.createDecipher(algorithm,key)odecipher.update(data,input_encoding='binary',output_encoding='binary')odecipher.final(output_encoding='binary')ocrypto.createSign(algorithm)osigner.update(data)osigner.sign(private_key,output_format='binary')ocrypto.createVerify(algorithm)overifier.update(data)overifier.verify(cert,signature,signature_format='binary')TLS(SSL)TLS(SSL)模块os=tls.connect(port,[host],[options],callback)otls.Servertls.createServer(options,secureConnectionListener)Event:'secureConnection'事件:'secureConnection'server.listen(port,[host],[callback])server.close()server.maxConnectionsserver.connectionsFileSystem文件系统模块ofs.rename(path1,path2,[callback])ofs.renameSync(path1,path2)ofs.truncate(fd,len,[callback])ofs.truncateSync(fd,len)ofs.chmod(path,mode,[callback])ofs.chmodSync(path,mode)ofs.stat(path,[callback])ofs.lstat(path,[callback])ofs.fstat(fd,[callback])ofs.statSync(path)ofs.lstatSync(path)ofs.fstatSync(fd)ofs.link(srcpath,dstpath,[callback])ofs.linkSync(srcpath,dstpath)ofs.symlink(linkdata,path,[callback])ofs.symlinkSync(linkdata,path)ofs.readlink(path,[callback])ofs.readlinkSync(path)ofs.realpath(path,[callback])ofs.realpathSync(path)ofs.unlink(path,[callback])ofs.unlinkSync(path)ofs.rmdir(path,[callback])ofs.rmdirSync(path)ofs.mkdir(path,mode,[callback])ofs.mkdirSync(path,mode)ofs.readdir(path,[callback])ofs.readdirSync(path)ofs.close(fd,[callback])ofs.closeSync(fd)ofs.open(path,flags,mode=0666,[callback])ofs.openSync(path,flags,mode=0666)ofs.utimes(path,atime,mtime,callback)ofs.utimesSync(path,atime,mtime)ofs.futimes(path,atime,mtime,callback)ofs.futimesSync(path,atime,mtime)ofs.write(fd,buffer,offset,length,position,[callback])ofs.writeSync(fd,buffer,offset,length,position)ofs.writeSync(fd,str,position,encoding='utf8')ofs.read(fd,buffer,offset,length,posi
本文标题:nodejs手册中文版
链接地址:https://www.777doc.com/doc-5948964 .html