Methods
bufferToStream(buffer)
- Description:
buffer 转 stream
- Source:
- Since:
- 0.0.1
Example
const buf = Buffer.from('hello world');
const stream = bufferToStream(buf); // stream instanceof Stream
Parameters:
Name | Type | Description |
---|---|---|
buffer |
buffer 对象 |
Returns:
stream 对象
getBuffer(input)
- Description:
获取本地或远程文件 buffer
- Source:
- Since:
- 0.0.1
Example
const buf1 = await getBuffer('./text.txt');
const buf2 = await getBuffer('some url or image');
Parameters:
Name | Type | Description |
---|---|---|
input |
本地或远程文件地址 |
Returns:
buffer 对象
streamToBuffer(stream)
- Description:
stream 转 buffer
- Source:
- Since:
- 0.0.1
Example
const stream = fs.createReadStream('./text.txt');
const buf = await streamToBuffer(stream);
Parameters:
Name | Type | Description |
---|---|---|
stream |
stream 对象 |
Returns:
buffer 对象