
## :StreamWorker
StreamWorker class - intended for internal use
This class provides control over the subprocesses, including:
- spawning
- communicating
- delivering streams
**Kind**: static class
**Internal**:
* [:StreamWorker](#module_scramjet.StreamWorker)
* [new StreamWorker()](#new_module_scramjet.StreamWorker_new)
* [streamWorker.spawn()](#module_scramjet.StreamWorker+spawn) ⇄ [StreamWorker](stream-worker.md#module_scramjet.StreamWorker)
* [streamWorker.delegate(input, delegateFunc, [plugins])](#module_scramjet.StreamWorker+delegate) [DataStream](data-stream.md#module_scramjet.DataStream)
* [StreamWorker:fork([count])](#module_scramjet.StreamWorker.fork) ⇄ Array.<StreamWorker>
* [StreamWorker:_getWorker()](#module_scramjet.StreamWorker._getWorker) ⇄ [StreamWorker](stream-worker.md#module_scramjet.StreamWorker)
### new StreamWorker()
Private constructor
### streamWorker.spawn() : StreamWorker ⇄
Spawns the worker if necessary and provides the port information to it.
**Kind**: instance method of [StreamWorker](#module_scramjet.StreamWorker)
### streamWorker.delegate(input, delegateFunc, [plugins]) : DataStream
Delegates a stream to the child using tcp socket.
The stream gets serialized using JSON and passed on to the sub-process.
The sub-process then performs transforms on the stream and pushes them back to the main process.
The stream gets deserialized and outputted to the returned DataStream.
**Kind**: instance method of [StreamWorker](#module_scramjet.StreamWorker)
**Returns**: [DataStream](data-stream.md#module_scramjet.DataStream) - stream after transforms and back to the main process.
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| input | [DataStream](data-stream.md#module_scramjet.DataStream) | | stream to be delegated |
| delegateFunc | Array.<TeeCallback> \| Array | | Array of transforms or arrays describing ['module', 'method'] |
| [plugins] | Array.<any> | [] | List of plugins to load in the child |
### StreamWorker:fork([count]) : Array. ⇄
Spawns (Preforks) a given number of subprocesses and returns the worker asynchronously.
**Kind**: static method of [StreamWorker](#module_scramjet.StreamWorker)
**Returns**: Array.<StreamWorker> - list of StreamWorkers
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [count] | number | os.cpus().length | Number of processes to spawn. If other subprocesses are active only the missing ones will be spawned. |
### StreamWorker:_getWorker() : StreamWorker ⇄
Picks next worker (not necessarily free one!)
**Kind**: static method of [StreamWorker](#module_scramjet.StreamWorker)