Comments (9)
没有太明白
from fibjs.
其实是想使用类似Node中 Buffer.concat()这样的方法合并多个Buffer对象
目前fibjs没这方法
于是我就直接把多个Buffer对象放在数组里面作为参数来new一个Buffer
from fibjs.
var a = new Buffer([0x01,0x02,0x03]);
var b = new Buffer([0x04,0x05,0x06]);
var c=new Buffer();
c.write(a)
c.write(b)
console.log(c.length)
6
console.log(c.hex());
010203040506
@illuspas
文檔上那個傳Array的構造函數 不是你這個意思。。
from fibjs.
我的意思是:傳Array的構造函數 能不能就是我這個意思。。
from fibjs.
那就不是構造函數的問題了
那是需要修改Array的構造函數了,比如說改成:
在兩個參數都是Buffer的情況,把Buffer內的內容按順序拼成一個Array
這顯然不行啊
from fibjs.
好吧,其实Node里也不能这么构造
要不然就实现 Buffer.concat 这个类方法 以前用node写的程序移植起来就更简单了
from fibjs.
@illuspas 我来尝试加 Buffer.concat
from fibjs.
我发现 write(Array data)时,只是简单调用了 toString,这样的话这个重载似乎没什么意义,
我感觉 Buffer 的很多地方都不对,相比较nodejs 1)它不应该建立在 std::string 下,它应该是个固定数组,这样的话 write 和 writeXXXX 应该一致,不允许调整尺寸, 2) 移除 resize, 3) 就大数语言的规范,slice 并不会修改原对象,nodejs 也符合,它返回的Buffer是建立在原Buffer上的引用, 修改原对象的应该叫 splice, 还有 slice 的第二个参数 end为负数时,和 str.slice 处理的不一致
from fibjs.
Buffer 的一些实现的确与 nodejs 不兼容,这部分已经安排计划在修改了,多谢关注。
from fibjs.
Related Issues (20)
- Private instance method SyntaxError HOT 2
- Fibjs shell "Error: [2] 系统找不到指定的文件" but nodejs shell works
- ChildProcess.join() returns undefined but should return the child process exit code by fibjs website document
- The "fail" method undefined in assert but it added in node v0.1.21
- Fibjs shell can't print ".0"(command not found) but nodejs can do
- "stdio: ['ipc']" not documented in fibjs website and child_process.send() works only in this 'ipc' case HOT 1
- 'Error: [4092] permission denied' raised after calling socket bind pipe on windows HOT 3
- Fibjs repl can't correctly print '吉' that built from Buffer but node works
- One file can't use the another one in the files cross referenced HOT 1
- 疑似 http.Client 的 bug
- No the timeout version of the method coroutine.Lock.acquire() HOT 2
- Document error about the arg start of Buffer.set(Buffer src, Integer start)
- How to distinguish sql execution error from connection issue of DbConnection execute()?
- How to get field or result data types(eg. varchar, date, time, timestamp) of a sql query in DbConnection?
- Can support the argument Buffer for Stream.read()? It's useful when have a customized buffer management
- How to fetch row from DbConnection instead of all data?
- How to access column value of result set by column index in db module?
- Redis模块的incr/decr返回值错误
- Decryption of block requires a full block in cipher.encrypt() HOT 1
- The parameter data of process.stdin.read() in async mode is undefined in fibjs src "test\process\exec.parallel_stdin.js" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fibjs.