buffer-pipe
Advanced tools
Comparing version 0.0.1 to 0.0.2
26
API.md
@@ -9,6 +9,8 @@ <!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
- [end](#end) | ||
- [bytesRead](#bytesread) | ||
- [bytesWrote](#byteswrote) | ||
## constructor | ||
[index.js:8-10](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L8-L10 "Source code on GitHub") | ||
[index.js:8-12](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L8-L12 "Source code on GitHub") | ||
@@ -23,3 +25,3 @@ Creates a new instance of a pipe | ||
[index.js:17-21](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L17-L21 "Source code on GitHub") | ||
[index.js:19-24](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L19-L24 "Source code on GitHub") | ||
@@ -36,3 +38,3 @@ read `num` number of bytes from the pipe | ||
[index.js:27-30](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L27-L30 "Source code on GitHub") | ||
[index.js:30-34](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L30-L34 "Source code on GitHub") | ||
@@ -47,5 +49,21 @@ Wites a buffer to the pipe | ||
[index.js:36-38](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L36-L38 "Source code on GitHub") | ||
[index.js:40-42](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L40-L42 "Source code on GitHub") | ||
Whether or not there is more data to read from the buffer | ||
returns {Boolean} | ||
## bytesRead | ||
[index.js:48-50](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L48-L50 "Source code on GitHub") | ||
returns the number of bytes read from the stream | ||
Returns **Integer** | ||
## bytesWrote | ||
[index.js:56-58](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L56-L58 "Source code on GitHub") | ||
returns the number of bytes wrote to the stream | ||
Returns **Integer** |
20
index.js
@@ -10,2 +10,4 @@ const Buffer = require('safe-buffer').Buffer | ||
this.buffer = buf | ||
this._bytesRead = 0 | ||
this._bytesWrote = 0 | ||
} | ||
@@ -19,2 +21,3 @@ | ||
read (num) { | ||
this._bytesRead += num | ||
const data = this.buffer.subarray(0, num) | ||
@@ -31,2 +34,3 @@ this.buffer = this.buffer.subarray(num) | ||
buf = Buffer.from(buf) | ||
this._bytesWrote += buf.length | ||
this.buffer = Buffer.concat([this.buffer, buf]) | ||
@@ -42,2 +46,18 @@ } | ||
} | ||
/** | ||
* returns the number of bytes read from the stream | ||
* @return {Integer} | ||
*/ | ||
get bytesRead () { | ||
return this._bytesRead | ||
} | ||
/** | ||
* returns the number of bytes wrote to the stream | ||
* @return {Integer} | ||
*/ | ||
get bytesWrote () { | ||
return this._bytesWrote | ||
} | ||
} |
{ | ||
"name": "buffer-pipe", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "A simple pipe for buffers", | ||
@@ -22,4 +22,3 @@ "main": "index.js", | ||
"coveralls": "^3.0.0", | ||
"istanbul": "^0.4.1", | ||
"nyc": "^11.3.0", | ||
"nyc": "^11.4.1", | ||
"standard": "^10.0.0", | ||
@@ -26,0 +25,0 @@ "tape": "^4.0.3" |
@@ -28,5 +28,6 @@ # SYNOPSIS | ||
## constructor | ||
[index.js:8-10](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L8-L10 "Source code on GitHub") | ||
[index.js:8-12](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L8-L12 "Source code on GitHub") | ||
@@ -41,3 +42,3 @@ Creates a new instance of a pipe | ||
[index.js:17-21](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L17-L21 "Source code on GitHub") | ||
[index.js:19-24](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L19-L24 "Source code on GitHub") | ||
@@ -54,3 +55,3 @@ read `num` number of bytes from the pipe | ||
[index.js:27-30](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L27-L30 "Source code on GitHub") | ||
[index.js:30-34](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L30-L34 "Source code on GitHub") | ||
@@ -65,3 +66,3 @@ Wites a buffer to the pipe | ||
[index.js:36-38](https://github.com/wanderer/buffer-pipe/blob/54caadc458ca1ac4c3d5d42c945f09165d3f15cd/index.js#L36-L38 "Source code on GitHub") | ||
[index.js:40-42](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L40-L42 "Source code on GitHub") | ||
@@ -71,2 +72,18 @@ Whether or not there is more data to read from the buffer | ||
## bytesRead | ||
[index.js:48-50](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L48-L50 "Source code on GitHub") | ||
returns the number of bytes read from the stream | ||
Returns **Integer** | ||
## bytesWrote | ||
[index.js:56-58](https://github.com/wanderer/buffer-pipe/blob/9aa3e2f794fab45e36fada634829fdb4260dcdea/index.js#L56-L58 "Source code on GitHub") | ||
returns the number of bytes wrote to the stream | ||
Returns **Integer** | ||
# LICENSE | ||
@@ -73,0 +90,0 @@ [MPL-2.0][LICENSE] |
@@ -12,2 +12,3 @@ const tape = require('tape') | ||
t.equals(p.bytesRead, 3, 'should record the number of bytes read from the pipe') | ||
t.deepEquals(buf, Buffer.from([1, 2, 3])) | ||
@@ -18,2 +19,3 @@ t.equal(p.end, false) | ||
p.write(Buffer.from([99])) | ||
t.equals(p.bytesWrote, 1, 'should record the number of bytes written to a the pipe') | ||
@@ -20,0 +22,0 @@ t.deepEquals(p.buffer, Buffer.from([99])) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
77002
4
484
88