Home  >  Article  >  Web Front-end  >  node.js中的buffer.fill方法使用说明_node.js

node.js中的buffer.fill方法使用说明_node.js

WBOY
WBOYOriginal
2016-05-16 16:27:171768browse

方法说明:

将制定数据填充到buffer中。

语法:

复制代码 代码如下:

buffer.fill(value, [offset], [end])

接收参数:

value           将要填充的数据

offet           填充数据的开始位置,不指定默认为 0

end            填充数据的结束位置,不指定默认为 buffer 的 长度。

例子:

复制代码 代码如下:

//例子1中,不指定填充内容的起止位置
var b = new Buffer(50);
b.fill("h");
 
//例子2中,指定了填充内容的起止位置
var b = new Buffer(50);
var len = b.length;
b.fill("h" , len-1 , len);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn