Simulator first commit

This commit is contained in:
2019-09-18 11:11:16 +03:00
commit 6e1686be67
5028 changed files with 985331 additions and 0 deletions

3
node_modules/stream-chunker/.npmignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
/node_modules
/coverage
/npm-debug.log

11
node_modules/stream-chunker/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,11 @@
language: node_js
node_js:
- "stable"
- "4.1"
- "4.0"
- "0.12"
- "0.11"
- "0.10"
- "iojs"
after_success:
- npm run coveralls

65
node_modules/stream-chunker/README.md generated vendored Normal file
View File

@ -0,0 +1,65 @@
# stream-chunker
A transform stream which chunks incoming data into `chunkSize` byte chunks.
[![NPM](https://nodei.co/npm/stream-chunker.png)](https://nodei.co/npm/stream-chunker/)
[![Build Status](https://travis-ci.org/klyngbaek/stream-chunker.svg?branch=master)](https://travis-ci.org/klyngbaek/stream-chunker)
[![Coverage Status](https://coveralls.io/repos/github/klyngbaek/stream-chunker/badge.svg?branch=master)](https://coveralls.io/github/klyngbaek/stream-chunker?branch=master)
[![Dependency Status](https://david-dm.org/klyngbaek/stream-chunker.svg)](https://david-dm.org/klyngbaek/stream-chunker)
[![devDependency Status](https://david-dm.org/klyngbaek/stream-chunker/dev-status.svg)](https://david-dm.org/klyngbaek/stream-chunker#info=devDependencies)
## API
#### `var chunker = require('stream-chunker')(chunkSize, [opts])`
Returns a new chunker. Chunker is a duplex (transform) stream. You can write data into the
chunker, and regardless of the incoming data, the readable side will emit data
in `chunkSize` byte chunks. This modules has no notion of `objectMode`, everything
written to this stream must be a `string` or a `buffer`.
- `chunkSize`: `integer` - Size in bytes of the desired chunks.
- `opts`
- `flush`: `boolean` - Optional. Flush incomplete chunk data on stream end. Default is `false`.
- `align`: `boolean` - Optional. Pad incomplete chunk data on stream end. Should be used in combination with `flush`. Default is `false`.
- `encoding`: `string` - Optional. Encoding of String chunks. Must be a valid Buffer encoding, such as `utf8` or `ascii`.
## Simple Example
```javascript
var fs = require('fs');
var chunker = require('stream-chunker');
fs.createReadStream('/someFile')
.pipe(chunker(16))
.pipe(somethingThatExpects16ByteChunks());
```
## Full Working Example
```javascript
// Create sample input stream with 10 byte chunks
var Lorem = require('loremipstream');
var sampleStream = new Lorem({
size: 100,
dataSize: 10,
dataInteval: 100
});
// Create stream chunker with 16 byte chunks
var Chunker = require('stream-chunker');
var opts = {
flush: true,
encoding: 'utf8'
};
var chunker = Chunker(16, opts);
// make sure to add any data event listeners to chunker stream
// before you write any data to it
chunker.on('data', function(data) {
// do something with a chunk of data
// notice the last chunk is the flushed data
console.log('Chunk: ' + data);
});
sampleStream.pipe(chunker); // write some data to chunker to get chunked
```
## License
MIT

23
node_modules/stream-chunker/example/lorem.js generated vendored Normal file
View File

@ -0,0 +1,23 @@
// Create sample input stream with 10 byte chunks
var Lorem = require('loremipstream');
var sampleStream = new Lorem({
size: 100,
dataSize: 10,
dataInteval: 100
});
// Create stream chunker with 16 byte chunks
var Chunker = require('../index.js');
var opts = {
flush: true,
encoding: 'utf8'
};
var chunker = Chunker(16, opts); // split the stream of data into 4 byte chunks
// make sure to add any data event listeners to chunker stream
// before you write any data to it
chunker.on('data', function(data) {
// do something with a chunk of data
// notice the last chunk is the flushed data
console.log('Chunk: ' + data);
});
sampleStream.pipe(chunker); // write some data to chunker to get chunked

62
node_modules/stream-chunker/index.js generated vendored Normal file
View File

@ -0,0 +1,62 @@
/**
* @copyright (c) 2014-2015 Kristian Lyngbaek
* @author Kristian Lyngbaek
* @module stream-chunker
*/
var through2 = require('through2');
/**
* Returns a transform stream which chunks incoming data into chunkSize byte
* chunks.
* @param {integer} chunkSize Size of chunks in bytes
* @param {boolean} [flush] Flush incomplete chunk data on stream end
* Default is false
* @return {Stream.Transform} A transform stream
*/
module.exports = function (chunkSize, opts) {
if (!opts) opts = {};
var flush = opts.flush;
var encoding = opts.encoding;
// buffer to store the last few bytes of incoming data
// if it does not divide evenly into chunkSize
var buffer = new Buffer(0);
var transformOpts = {
encoding: encoding,
halfOpen: false,
objectMode: false
};
var transformFunction = function (data, enc, next) {
var allData = Buffer.concat([buffer, data]);
var totalLength = allData.length;
var remainder = totalLength % chunkSize;
var cutoff = totalLength - remainder;
for (var i=0 ; i<cutoff ; i+=chunkSize) {
var chunk = allData.slice(i, i+chunkSize);
this.push(chunk);
}
buffer = allData.slice(cutoff, totalLength);
next();
};
var flushFunction;
if (flush) {
flushFunction = function (next) {
if (opts.align && buffer.length > 0) {
var remaining = new Buffer(chunkSize - buffer.length);
remaining.fill(0);
buffer = Buffer.concat([ buffer, remaining ], chunkSize);
}
this.push(buffer);
next();
};
}
return through2(transformOpts, transformFunction, flushFunction);
};

21
node_modules/stream-chunker/license generated vendored Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Kristian Lyngbaek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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 OR COPYRIGHT HOLDERS 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.

72
node_modules/stream-chunker/package.json generated vendored Normal file
View File

@ -0,0 +1,72 @@
{
"_from": "stream-chunker@^1.2.8",
"_id": "stream-chunker@1.2.8",
"_inBundle": false,
"_integrity": "sha1-6zryyK7lJWzedvCh/qhjSDNtBPc=",
"_location": "/stream-chunker",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "stream-chunker@^1.2.8",
"name": "stream-chunker",
"escapedName": "stream-chunker",
"rawSpec": "^1.2.8",
"saveSpec": null,
"fetchSpec": "^1.2.8"
},
"_requiredBy": [
"/"
],
"_resolved": "https://registry.npmjs.org/stream-chunker/-/stream-chunker-1.2.8.tgz",
"_shasum": "eb3af2c8aee5256cde76f0a1fea86348336d04f7",
"_spec": "stream-chunker@^1.2.8",
"_where": "/home/sergiu/linx-audio-simulator",
"author": {
"name": "Kristian Lyngbaek"
},
"bugs": {
"url": "https://github.com/klyngbaek/stream-chunker/issues"
},
"bundleDependencies": false,
"dependencies": {
"through2": "~2.0.0"
},
"deprecated": false,
"description": "A transform stream which chunks incoming data into chunkSize byte chunks",
"devDependencies": {
"chunky": "~0.0.0",
"concat-stream": "~1.5.0",
"coveralls": "^2.11.6",
"istanbul": "^0.4.2",
"jshint": "^2.9.1",
"loremipstream": "~0.0.3 ",
"tape": "~4.4.0"
},
"homepage": "https://github.com/klyngbaek/stream-chunker",
"keywords": [
"stream",
"chunk",
"chunker",
"splitter",
"split",
"byte",
"buffer",
"binary",
"transform"
],
"license": "MIT",
"main": "index.js",
"name": "stream-chunker",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/klyngbaek/stream-chunker.git"
},
"scripts": {
"cover": "istanbul cover tape test/*",
"coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls",
"lint": "jshint **.js",
"test": "npm run lint && tape test/*"
},
"version": "1.2.8"
}

43
node_modules/stream-chunker/test/float.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
var Chunker = require('../index.js');
var test = require('tape');
var chunky = require('chunky');
test('Test back-to-back float encoding', function (t) {
t.plan(500);
var buffer = new Buffer(16*100);
for (var i=0 ; i<100 ; i++) {
buffer.writeFloatBE(i/8, i*16+0);
buffer.writeFloatBE(-i*4, i*16+4);
buffer.writeFloatBE(i*2, i*16+8);
buffer.writeFloatBE(-i, i*16|+12);
}
var chunks = chunky(buffer);
var chunker = Chunker(16);
var k=0;
chunker.on('data', function (data) {
t.equals(data.length, 16, 'Chunk size correct');
var a = data.readFloatBE(0);
var b = data.readFloatBE(4);
var c = data.readFloatBE(8);
var d = data.readFloatBE(12);
t.equals(a, k/8, 'First float correctly parsed');
t.equals(b, -k*4, 'Second float correctly parsed');
t.equals(c, k*2, 'Third float correctly parsed');
t.equals(d, -k, 'Fourth float correctly parsed');
k++;
});
for (var j=0 ; j<chunks.length ; j++) {
chunker.write(chunks[j]);
}
});

74
node_modules/stream-chunker/test/flush.js generated vendored Normal file
View File

@ -0,0 +1,74 @@
var Chunker = require('../index.js');
var test = require('tape');
var concat = require('concat-stream');
test('Test flush option', function (t) {
t.plan(2);
var opts = {
flush: false,
encoding: 'utf8'
}
function check(data) {
t.equals(data, '1234', 'Received only full chunks');
}
var chunker = Chunker(4, opts);
var concatStream = concat(check);
chunker.pipe(concatStream);
chunker.write('12');
chunker.write('34');
chunker.write('56');
chunker.end();
var optsFlush = {
flush: true,
encoding: 'utf8'
}
function checkFlush(data) {
t.equals(data, '123456', 'Received flush data');
}
var chunkerFlush = Chunker(4, optsFlush);
var concatStreamFlush = concat(checkFlush);
chunkerFlush.pipe(concatStreamFlush);
chunkerFlush.write('12');
chunkerFlush.write('34');
chunkerFlush.write('56');
chunkerFlush.end();
});
test('Test align option', function (t) {
t.plan(2);
var optsFlushAlign = {
flush: true,
align: true,
encoding: 'utf8'
}
function checkFlushAlign(data) {
t.equals(data, '12345\0\0\0', 'Received flush data');
}
var chunkerFlushAlign = Chunker(4, optsFlushAlign);
var concatStreamFlushAlign = concat(checkFlushAlign);
chunkerFlushAlign.pipe(concatStreamFlushAlign);
chunkerFlushAlign.write('12');
chunkerFlushAlign.write('34');
chunkerFlushAlign.write('5');
chunkerFlushAlign.end();
function checkAlignedFlushAlign(data) {
t.equals(data, '1234', 'Received flush data');
}
var chunkerAlignedFlushAlign = Chunker(4, optsFlushAlign);
var concatStreamAlignedFlushAlign = concat(checkAlignedFlushAlign);
chunkerAlignedFlushAlign.pipe(concatStreamAlignedFlushAlign);
chunkerAlignedFlushAlign.write('12');
chunkerAlignedFlushAlign.write('34');
chunkerAlignedFlushAlign.end();
});