Add node modules and compiled JavaScript from main (#54)
Co-authored-by: Oliver King <oking3@uncc.edu>
This commit is contained in:
committed by
GitHub
parent
4a983766a0
commit
52d71d28bd
12
node_modules/stream-buffers/.codeclimate.yml
generated
vendored
Normal file
12
node_modules/stream-buffers/.codeclimate.yml
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
engines:
|
||||
eslint:
|
||||
enabled: true
|
||||
fixme:
|
||||
enabled: true
|
||||
ratings:
|
||||
paths:
|
||||
- "**.js"
|
||||
exclude_paths:
|
||||
- node_modules/**/*
|
||||
- test/**/*
|
1
node_modules/stream-buffers/.eslintignore
generated
vendored
Normal file
1
node_modules/stream-buffers/.eslintignore
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
coverage/
|
25
node_modules/stream-buffers/.eslintrc
generated
vendored
Normal file
25
node_modules/stream-buffers/.eslintrc
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"rules": {
|
||||
"indent": [
|
||||
2,
|
||||
2
|
||||
],
|
||||
"quotes": [
|
||||
2,
|
||||
"single"
|
||||
],
|
||||
"linebreak-style": [
|
||||
2,
|
||||
"unix"
|
||||
],
|
||||
"semi": [
|
||||
2,
|
||||
"always"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"node": true,
|
||||
"mocha": true
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
3
node_modules/stream-buffers/.mailmap
generated
vendored
Normal file
3
node_modules/stream-buffers/.mailmap
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
Sam Day <sam.c.day@gmail.com>
|
||||
Sam Day <me@samcday.com.au>
|
||||
Sam Day <me@samcday.com>
|
1
node_modules/stream-buffers/.nvmrc
generated
vendored
Normal file
1
node_modules/stream-buffers/.nvmrc
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
v8.4
|
32
node_modules/stream-buffers/.travis.yml
generated
vendored
Normal file
32
node_modules/stream-buffers/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
language: node_js
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
matrix:
|
||||
include:
|
||||
- node_js: '0.10'
|
||||
- node_js: '0.12'
|
||||
- node_js: '4.2'
|
||||
- node_js: '5.0'
|
||||
- node_js: '6.0'
|
||||
- node_js: '8.4'
|
||||
env: npm_config_coverage=1
|
||||
addons:
|
||||
code_climate:
|
||||
repo_token:
|
||||
secure: "qoQoeJZrjiE7RmcGIZNmR2tO3/oP1NqlxhYkj1TYbMVOYmK4zsOdeVjhllkETZaGejKcw1uXEQx7caSmpZQ6lw5V5JXmyyTzo8xfAbanP9Wf4WXw5uSOaBDYR/DR2B9VfkHT7spPVwdoX09sgb+oTIy4IgBUivucm6IGmiw7PuY="
|
||||
after_success: |
|
||||
if [ -n "$npm_config_coverage" ]; then
|
||||
npm install -g codeclimate-test-reporter
|
||||
codeclimate-test-reporter < coverage/lcov.info
|
||||
fi
|
||||
deploy:
|
||||
provider: npm
|
||||
email: me@samcday.com.au
|
||||
api_key:
|
||||
secure: GiLpIWPU/TFJ5JVSHbu1eLN3Bx/mpuVtSh0FIwXP0mlBNzKq/y2pTrdzAx+Lp9s8lTvJl8kBE2hdaQMMpHHK7OoAaqykU2DCKPMSD2/mBxjzq3XjP/f3t7/sIpMv8ZZ/kUFmzyHcZv+zAIlFx39IQl5C9o1L2LYkG3EDaiiMzi8=
|
||||
on:
|
||||
tags: true
|
||||
all_branches: true
|
||||
node_js: 8.4
|
167
node_modules/stream-buffers/README.md
generated
vendored
Normal file
167
node_modules/stream-buffers/README.md
generated
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
# Node Stream Buffers
|
||||
|
||||
[![Build Status][badge-travis-img]][badge-travis-url]
|
||||
[![Dependency Information][badge-david-img]][badge-david-url]
|
||||
[![Code Climate][badge-climate-img]][badge-climate-url]
|
||||
[![Code Coverage][badge-coverage-img]][badge-coverage-url]
|
||||
[![npm][badge-npm-img]][badge-npm-url]
|
||||
|
||||
Simple Readable and Writable Streams that use a [Buffer][node-buffer-docs] to store received data, or for data to send out. Useful for test code, debugging, and a wide range of other utilities.
|
||||
|
||||
```
|
||||
npm install stream-buffers --save
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
To use the stream buffers in your module, simply import it and away you go.
|
||||
|
||||
```js
|
||||
var streamBuffers = require('stream-buffers');
|
||||
```
|
||||
|
||||
### WritableStreamBuffer
|
||||
|
||||
`WritableStreamBuffer` implements the standard [`stream.Writable`](https://nodejs.org/api/stream.html#stream_class_stream_writable) interface. All writes to this stream will accumulate in an internal [`Buffer`](https://nodejs.org/api/buffer.html). If the internal buffer overflows it will be resized automatically. The initial size of the Buffer and the amount in which it grows can be configured in the constructor.
|
||||
|
||||
```js
|
||||
var myWritableStreamBuffer = new streamBuffers.WritableStreamBuffer({
|
||||
initialSize: (100 * 1024), // start at 100 kilobytes.
|
||||
incrementAmount: (10 * 1024) // grow by 10 kilobytes each time buffer overflows.
|
||||
});
|
||||
```
|
||||
|
||||
The default initial size and increment amount are stored in the following constants:
|
||||
|
||||
```js
|
||||
streamBuffers.DEFAULT_INITIAL_SIZE // (8 * 1024)
|
||||
streamBuffers.DEFAULT_INCREMENT_AMOUNT // (8 * 1024)
|
||||
```
|
||||
|
||||
Writing is standard Stream stuff:
|
||||
|
||||
```js
|
||||
myWritableStreamBuffer.write(myBuffer);
|
||||
// - or -
|
||||
myWritableStreamBuffer.write('\u00bd + \u00bc = \u00be', 'utf8');
|
||||
```
|
||||
|
||||
You can query the size of the data being held in the Buffer, and also how big the Buffer's max capacity currently is:
|
||||
|
||||
```js
|
||||
myWritableStreamBuffer.write('ASDF');
|
||||
streamBuffers.size(); // 4.
|
||||
streamBuffers.maxSize(); // Whatever was configured as initial size. In our example: (100 * 1024).
|
||||
```
|
||||
|
||||
Retrieving the contents of the Buffer is simple.
|
||||
|
||||
```js
|
||||
// Gets all held data as a Buffer.
|
||||
myWritableStreamBuffer.getContents();
|
||||
|
||||
// Gets all held data as a utf8 string.
|
||||
myWritableStreamBuffer.getContentsAsString('utf8');
|
||||
|
||||
// Gets first 5 bytes as a Buffer.
|
||||
myWritableStreamBuffer.getContents(5);
|
||||
|
||||
// Gets first 5 bytes as a utf8 string.
|
||||
myWritableStreamBuffer.getContentsAsString('utf8', 5);
|
||||
```
|
||||
|
||||
**Care should be taken when getting encoded strings from WritableStream, as it doesn't really care about the contents (multi-byte characters will not be respected).**
|
||||
|
||||
Destroying or ending the WritableStream will not delete the contents of Buffer, but will disallow any further writes.
|
||||
|
||||
```js
|
||||
myWritableStreamBuffer.write('ASDF');
|
||||
myWritableStreamBuffer.end();
|
||||
myWritableStreamBuffer.getContentsAsString(); // -> 'ASDF'
|
||||
```
|
||||
|
||||
### ReadableStreamBuffer
|
||||
|
||||
`ReadableStreamBuffer` implements the standard [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable), but can have data inserted into it. This data will then be pumped out in chunks as readable events. The data to be sent out is held in a Buffer, which can grow in much the same way as a `WritableStreamBuffer` does, if data is being put in Buffer faster than it is being pumped out.
|
||||
|
||||
The frequency in which chunks are pumped out, and the size of the chunks themselves can be configured in the constructor. The initial size and increment amount of internal Buffer can be configured too. In the following example 2kb chunks will be output every 10 milliseconds:
|
||||
|
||||
```js
|
||||
var myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
|
||||
frequency: 10, // in milliseconds.
|
||||
chunkSize: 2048 // in bytes.
|
||||
});
|
||||
```
|
||||
|
||||
Default frequency and chunk size:
|
||||
|
||||
```js
|
||||
streamBuffers.DEFAULT_CHUNK_SIZE // (1024)
|
||||
streamBuffers.DEFAULT_FREQUENCY // (1)
|
||||
```
|
||||
|
||||
Putting data in Buffer to be pumped out is easy:
|
||||
|
||||
```js
|
||||
myReadableStreamBuffer.put(aBuffer);
|
||||
myReadableStreamBuffer.put('A String', 'utf8');
|
||||
```
|
||||
|
||||
Chunks are pumped out via standard `stream.Readable` semantics. This means you can use the old streams1 way:
|
||||
|
||||
```js
|
||||
myReadableStreamBuffer.on('data', function(data) {
|
||||
// streams1.x style data
|
||||
assert.isTrue(data instanceof Buffer);
|
||||
});
|
||||
```
|
||||
|
||||
Or the streams2+ way:
|
||||
|
||||
```js
|
||||
myReadableStreamBuffer.on('readable', function(data) {
|
||||
var chunk;
|
||||
while((chunk = myReadableStreamBuffer.read()) !== null) {
|
||||
assert.isTrue(chunk instanceof Buffer);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Because `ReadableStreamBuffer` is simply an implementation of [`stream.Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable), it implements pause / resume / setEncoding / etc.
|
||||
|
||||
Once you're done putting data into a `ReadableStreamBuffer`, you can call `stop()` on it.
|
||||
|
||||
```js
|
||||
myReadableStreamBuffer.put('the last data this stream will ever see');
|
||||
myReadableStreamBuffer.stop();
|
||||
```
|
||||
|
||||
Once the `ReadableStreamBuffer` is done pumping out the data in its internal buffer, it will emit the usual [`end`](https://nodejs.org/api/stream.html#stream_event_end) event. You cannot write any more data to the stream once you've called `stop()` on it.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
Not supposed to be a speed demon, it's more for tests/debugging or weird edge cases. It works with an internal buffer that it copies contents to/from/around.
|
||||
|
||||
## Contributors
|
||||
|
||||
Thanks to the following people for taking some time to contribute to this project.
|
||||
|
||||
* Igor Dralyuk <idralyuk@ebay.com>
|
||||
* Simon Koudijs <simon.koudijs@intellifi.nl>
|
||||
|
||||
## License
|
||||
|
||||
node-stream-buffer is free and unencumbered public domain software. For more information, see the accompanying UNLICENSE file.
|
||||
|
||||
[badge-travis-img]: http://img.shields.io/travis/samcday/node-stream-buffer.svg?style=flat-square
|
||||
[badge-travis-url]: https://travis-ci.org/samcday/node-stream-buffer
|
||||
[badge-david-img]: https://img.shields.io/david/samcday/node-stream-buffer.svg?style=flat-square
|
||||
[badge-david-url]: https://david-dm.org/samcday/node-stream-buffer
|
||||
[badge-climate-img]: http://img.shields.io/codeclimate/github/samcday/node-stream-buffer.svg?style=flat-square
|
||||
[badge-climate-url]: https://codeclimate.com/github/samcday/node-stream-buffer
|
||||
[badge-coverage-img]: http://img.shields.io/codeclimate/coverage/github/samcday/node-stream-buffer.svg?style=flat-square
|
||||
[badge-coverage-url]: https://codeclimate.com/github/samcday/node-stream-buffer
|
||||
[badge-npm-img]: https://img.shields.io/npm/dm/stream-buffers.svg?style=flat-square
|
||||
[badge-npm-url]: https://www.npmjs.org/package/stream-buffers
|
||||
|
||||
[node-buffer-docs]: http://nodejs.org/api/buffer.html
|
24
node_modules/stream-buffers/UNLICENSE
generated
vendored
Normal file
24
node_modules/stream-buffers/UNLICENSE
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <http://unlicense.org/>
|
8
node_modules/stream-buffers/lib/constants.js
generated
vendored
Normal file
8
node_modules/stream-buffers/lib/constants.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
DEFAULT_INITIAL_SIZE: (8 * 1024),
|
||||
DEFAULT_INCREMENT_AMOUNT: (8 * 1024),
|
||||
DEFAULT_FREQUENCY: 1,
|
||||
DEFAULT_CHUNK_SIZE: 1024
|
||||
};
|
114
node_modules/stream-buffers/lib/readable_streambuffer.js
generated
vendored
Normal file
114
node_modules/stream-buffers/lib/readable_streambuffer.js
generated
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
'use strict';
|
||||
|
||||
var stream = require('stream');
|
||||
var constants = require('./constants');
|
||||
var util = require('util');
|
||||
|
||||
var ReadableStreamBuffer = module.exports = function(opts) {
|
||||
var that = this;
|
||||
opts = opts || {};
|
||||
|
||||
stream.Readable.call(this, opts);
|
||||
|
||||
this.stopped = false;
|
||||
|
||||
var frequency = opts.hasOwnProperty('frequency') ? opts.frequency : constants.DEFAULT_FREQUENCY;
|
||||
var chunkSize = opts.chunkSize || constants.DEFAULT_CHUNK_SIZE;
|
||||
var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE;
|
||||
var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT;
|
||||
|
||||
var size = 0;
|
||||
var buffer = new Buffer(initialSize);
|
||||
var allowPush = false;
|
||||
|
||||
var sendData = function() {
|
||||
var amount = Math.min(chunkSize, size);
|
||||
var sendMore = false;
|
||||
|
||||
if (amount > 0) {
|
||||
var chunk = null;
|
||||
chunk = new Buffer(amount);
|
||||
buffer.copy(chunk, 0, 0, amount);
|
||||
|
||||
sendMore = that.push(chunk) !== false;
|
||||
allowPush = sendMore;
|
||||
|
||||
buffer.copy(buffer, 0, amount, size);
|
||||
size -= amount;
|
||||
}
|
||||
|
||||
if(size === 0 && that.stopped) {
|
||||
that.push(null);
|
||||
}
|
||||
|
||||
if (sendMore) {
|
||||
sendData.timeout = setTimeout(sendData, frequency);
|
||||
}
|
||||
else {
|
||||
sendData.timeout = null;
|
||||
}
|
||||
};
|
||||
|
||||
this.stop = function() {
|
||||
if (this.stopped) {
|
||||
throw new Error('stop() called on already stopped ReadableStreamBuffer');
|
||||
}
|
||||
this.stopped = true;
|
||||
|
||||
if (size === 0) {
|
||||
this.push(null);
|
||||
}
|
||||
};
|
||||
|
||||
this.size = function() {
|
||||
return size;
|
||||
};
|
||||
|
||||
this.maxSize = function() {
|
||||
return buffer.length;
|
||||
};
|
||||
|
||||
var increaseBufferIfNecessary = function(incomingDataSize) {
|
||||
if((buffer.length - size) < incomingDataSize) {
|
||||
var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount);
|
||||
|
||||
var newBuffer = new Buffer(buffer.length + (incrementAmount * factor));
|
||||
buffer.copy(newBuffer, 0, 0, size);
|
||||
buffer = newBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
var kickSendDataTask = function () {
|
||||
if (!sendData.timeout && allowPush) {
|
||||
sendData.timeout = setTimeout(sendData, frequency);
|
||||
}
|
||||
}
|
||||
|
||||
this.put = function(data, encoding) {
|
||||
if (that.stopped) {
|
||||
throw new Error('Tried to write data to a stopped ReadableStreamBuffer');
|
||||
}
|
||||
|
||||
if(Buffer.isBuffer(data)) {
|
||||
increaseBufferIfNecessary(data.length);
|
||||
data.copy(buffer, size, 0);
|
||||
size += data.length;
|
||||
}
|
||||
else {
|
||||
data = data + '';
|
||||
var dataSizeInBytes = Buffer.byteLength(data);
|
||||
increaseBufferIfNecessary(dataSizeInBytes);
|
||||
buffer.write(data, size, encoding || 'utf8');
|
||||
size += dataSizeInBytes;
|
||||
}
|
||||
|
||||
kickSendDataTask();
|
||||
};
|
||||
|
||||
this._read = function() {
|
||||
allowPush = true;
|
||||
kickSendDataTask();
|
||||
};
|
||||
};
|
||||
|
||||
util.inherits(ReadableStreamBuffer, stream.Readable);
|
5
node_modules/stream-buffers/lib/streambuffer.js
generated
vendored
Normal file
5
node_modules/stream-buffers/lib/streambuffer.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./constants');
|
||||
module.exports.ReadableStreamBuffer = require('./readable_streambuffer');
|
||||
module.exports.WritableStreamBuffer = require('./writable_streambuffer');
|
72
node_modules/stream-buffers/lib/writable_streambuffer.js
generated
vendored
Normal file
72
node_modules/stream-buffers/lib/writable_streambuffer.js
generated
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var stream = require('stream');
|
||||
var constants = require('./constants');
|
||||
|
||||
var WritableStreamBuffer = module.exports = function(opts) {
|
||||
opts = opts || {};
|
||||
opts.decodeStrings = true;
|
||||
|
||||
stream.Writable.call(this, opts);
|
||||
|
||||
var initialSize = opts.initialSize || constants.DEFAULT_INITIAL_SIZE;
|
||||
var incrementAmount = opts.incrementAmount || constants.DEFAULT_INCREMENT_AMOUNT;
|
||||
|
||||
var buffer = new Buffer(initialSize);
|
||||
var size = 0;
|
||||
|
||||
this.size = function() {
|
||||
return size;
|
||||
};
|
||||
|
||||
this.maxSize = function() {
|
||||
return buffer.length;
|
||||
};
|
||||
|
||||
this.getContents = function(length) {
|
||||
if(!size) return false;
|
||||
|
||||
var data = new Buffer(Math.min(length || size, size));
|
||||
buffer.copy(data, 0, 0, data.length);
|
||||
|
||||
if(data.length < size)
|
||||
buffer.copy(buffer, 0, data.length);
|
||||
|
||||
size -= data.length;
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
this.getContentsAsString = function(encoding, length) {
|
||||
if(!size) return false;
|
||||
|
||||
var data = buffer.toString(encoding || 'utf8', 0, Math.min(length || size, size));
|
||||
var dataLength = Buffer.byteLength(data);
|
||||
|
||||
if(dataLength < size)
|
||||
buffer.copy(buffer, 0, dataLength);
|
||||
|
||||
size -= dataLength;
|
||||
return data;
|
||||
};
|
||||
|
||||
var increaseBufferIfNecessary = function(incomingDataSize) {
|
||||
if((buffer.length - size) < incomingDataSize) {
|
||||
var factor = Math.ceil((incomingDataSize - (buffer.length - size)) / incrementAmount);
|
||||
|
||||
var newBuffer = new Buffer(buffer.length + (incrementAmount * factor));
|
||||
buffer.copy(newBuffer, 0, 0, size);
|
||||
buffer = newBuffer;
|
||||
}
|
||||
};
|
||||
|
||||
this._write = function(chunk, encoding, callback) {
|
||||
increaseBufferIfNecessary(chunk.length);
|
||||
chunk.copy(buffer, size, 0);
|
||||
size += chunk.length;
|
||||
callback();
|
||||
};
|
||||
};
|
||||
|
||||
util.inherits(WritableStreamBuffer, stream.Writable);
|
31
node_modules/stream-buffers/package.json
generated
vendored
Normal file
31
node_modules/stream-buffers/package.json
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "stream-buffers",
|
||||
"version": "3.0.2",
|
||||
"description": "Buffer-backed Streams for reading and writing.",
|
||||
"keywords": [
|
||||
"memory streams",
|
||||
"streams",
|
||||
"buffer streams"
|
||||
],
|
||||
"author": "Sam Day <me@samcday.com.au>",
|
||||
"main": "./lib/streambuffer.js",
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"chai": "^3.4.1",
|
||||
"eslint": "^1.9.0",
|
||||
"istanbul": "^0.4.0",
|
||||
"mocha": "^2.3.4"
|
||||
},
|
||||
"license": "Unlicense",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/samcday/node-stream-buffer.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "istanbul test _mocha",
|
||||
"lint": "eslint ."
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user