TypeError: argument should be a Buffer

1、毛病描写

> y.copy(0,10); TypeError: argument should be a Buffer at TypeError (native) at repl:1:3 at REPLServer.defaultEval (repl.js:262:27) at bound (domain.js:287:14) at REPLServer.runBound [as eval] (domain.js:300:12) at REPLServer.<anonymous> (repl.js:431:12) at emitOne (events.js:82:20) at REPLServer.emit (events.js:169:7) at REPLServer.Interface._onLine (readline.js:211:10) at REPLServer.Interface._line (readline.js:550:8) >

2、毛病缘由

     buffer.copy(Buffer对象,开始写入处);

     但是这里Buffer对象写成了0


3、解决办法

> y=Buffer('wo ai ni'); <Buffer 77 6f 20 61 69 20 6e 69> > o=Buffer(128); <Buffer 00 00 00 00 01 00 00 00 80 61 37 02 00 00 00 00 02 00 00 00 00 00 00 00 88 94 43 00 00 00 00 00 01 00 00 00 00 00 00 00 e8 aa 43 00 00 00 00 00 02 00 .. . > > o.fill(0); <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .. . > > o; <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .. . > > y.copy(0,10); TypeError: argument should be a Buffer at TypeError (native) at repl:1:3 at REPLServer.defaultEval (repl.js:262:27) at bound (domain.js:287:14) at REPLServer.runBound [as eval] (domain.js:300:12) at REPLServer.<anonymous> (repl.js:431:12) at emitOne (events.js:82:20) at REPLServer.emit (events.js:169:7) at REPLServer.Interface._onLine (readline.js:211:10) at REPLServer.Interface._line (readline.js:550:8) > y.copy(o,10); 8 > o; <Buffer 00 00 00 00 00 00 00 00 00 00 77 6f 20 61 69 20 6e 69 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .. . > >


相关文章

HTML代码中要想改变字体颜色,常常需要使用CSS样式表。CSS是...
HTML代码如何让字体盖住图片呢?需要使用CSS的position属性及...
HTML代码字体设置 在HTML中,我们可以使用标签来设置网页中的...
在网页设计中,HTML代码的字体和字号选择是非常重要的一个环...
HTML(Hypertext Markup Language,超文本标记语言)是一种用...
外链是指在一个网页中添加一个指向其他网站的链接,用户可以...