New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

scramjet

Package Overview
Dependencies
Maintainers
2
Versions
179
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scramjet - npm Package Compare versions

Comparing version 4.34.7 to 4.35.1

129

.d.ts/index.d.ts

@@ -1,2 +0,2 @@

import {Readable, Writable, Transform, WritableOptions} from "stream";
import {Readable, Writable, Transform} from "stream";

@@ -7,2 +7,3 @@ import {EventEmitter} from "events";

type AsyncFunction = (...args: any[]) => Promise<any>;
type ThenFunction = (arg: any) => any;

@@ -161,4 +162,16 @@ declare class PromiseTransform implements NodeJS.ReadableStream, NodeJS.WritableStream {

/**
* Create the DataStream.
* @param opts Stream options passed to superclass
* DataStream is the primary stream type for Scramjet. When you parse your
* stream, just pipe it you can then perform calculations on the data objects
* streamed through your flow.
*
* Use as:
*
* ```javascript
* const { DataStream } = require('scramjet');
*
* await (DataStream.from(aStream) // create a DataStream
* .map(findInFiles) // read some data asynchronously
* .map(sendToAPI) // send the data somewhere
* .run()); // wait until end
* ```
*/

@@ -191,8 +204,9 @@ constructor(opts?: DataStreamOptions);

* .from(function* () {
* while(x < 100) yield x++;
* while(x < 100) yield {x: x++};
* })
* .each(console.log)
* // 0
* // 1...
* // 99
* // {x: 0}
* // {x: 1}
* // ...
* // {x: 99}
* ```

@@ -203,3 +217,3 @@ * @param input argument to be turned into new stream

*/
static from(input: any[] | Iterable<any> | AsyncGeneratorFunction | GeneratorFunction | AsyncFunction | Function | string | Readable, options?: DataStreamOptions | Writable, ...args: any[]): DataStream;
static from(input: any[] | Iterable<any> | AsyncGeneratorFunction | GeneratorFunction | AsyncFunction | Promise<any> | Function | string | Readable, options?: DataStreamOptions | Writable, ...args: any[]): DataStream;

@@ -869,4 +883,3 @@ /**

*
* @param accumulator the accumulator - the object initially passed or returned
* by the previous reduce operation
* @param accumulator the accumulator - the object initially passed or returned by the previous reduce operation
* @param chunk the stream chunk.

@@ -879,4 +892,5 @@ */

* @param chunk source stream chunk
* @returns the outcome is discarded
*/
declare type DoCallback = (chunk: object)=>void;
declare type DoCallback = (chunk: object)=>Promise<any> | any;

@@ -888,3 +902,3 @@ /**

*/
declare type IntoCallback = (into: any, chunk: object)=>any;
declare type IntoCallback = (into: any, chunk: any)=>Promise<any> | any;

@@ -915,3 +929,3 @@ /**

*/
declare type ScramjetTransformCallback = (chunk: Buffer | string | any, encoding: string)=>any | undefined;
declare type ScramjetTransformCallback = (chunk: Buffer | string | any, encoding: string)=>Promise<any | undefined> | any | undefined;

@@ -922,4 +936,5 @@ /**

* @param encoding encoding of the chunk
* @returns should resolve when the write ends
*/
declare type ScramjetWriteCallback = (chunk: Buffer | string | any, encoding: string)=>void;
declare type ScramjetWriteCallback = (chunk: Buffer | string | any, encoding: string)=>Promise<void> | void;

@@ -931,3 +946,3 @@ /**

*/
declare type ScramjetReadCallback = (count: number)=>any[];
declare type ScramjetReadCallback = (count: number)=>any[] | Promise<Array<any>>;

@@ -984,4 +999,7 @@ /**

*
* ```javascript
* StringStream.fromString()
* ```js
* StringStream.from(async () => (await fetch('https://example.com/data/article.txt')).text())
* .lines()
* .append("\r\n")
* .pipe(fs.createWriteStream('./path/to/file.txt'))
* ```

@@ -991,5 +1009,12 @@ */

/**
* Constructs the stream with the given encoding
* @param encoding the encoding to use
* @param options the encoding to use
* A stream of string objects for further transformation on top of DataStream.
*
* Example:
*
* ```js
* StringStream.from(async () => (await fetch('https://example.com/data/article.txt')).text())
* .lines()
* .append("\r\n")
* .pipe(fs.createWriteStream('./path/to/file.txt'))
* ```
*/

@@ -1043,3 +1068,3 @@ constructor(encoding?: string, options?: DataStreamOptions);

*/
parse(parser: ParseCallback, StreamClass: Function): DataStream;
parse(parser: ParseCallback, StreamClass?: Function): DataStream;

@@ -1080,3 +1105,3 @@ /**

*/
lines(eol?: string): this;
lines(eol?: string | RegExp): this;

@@ -1100,3 +1125,3 @@ /**

*/
append(param: Function | string): this;
append(param: ThenFunction | string): this;

@@ -1108,3 +1133,3 @@ /**

*/
prepend(param: Function | string): this;
prepend(param: ThenFunction | string): this;

@@ -1137,3 +1162,3 @@ /**

*/
declare type ParseCallback = (chunk: string)=>Promise<any>;
declare type ParseCallback = (chunk: string)=>Promise<any> | any;

@@ -1161,4 +1186,19 @@ /**

/**
* Creates the BufferStream
* @param opts Stream options passed to superclass
* A facilitation stream created for easy splitting or parsing buffers.
*
* Useful for working on built-in Node.js streams from files, parsing binary formats etc.
*
* A simple use case would be:
*
* ```javascript
* fs.createReadStream('pixels.rgba')
* .pipe(new BufferStream) // pipe a buffer stream into scramjet
* .breakup(4) // split into 4 byte fragments
* .parse(buffer => [
* buffer.readInt8(0), // the output is a stream of R,G,B and Alpha
* buffer.readInt8(1), // values from 0-255 in an array.
* buffer.readInt8(2),
* buffer.readInt8(3)
* ]);
* ```
*/

@@ -1238,3 +1278,3 @@ constructor(opts?: DataStreamOptions);

*/
declare type BufferParseCallback = (chunk: Buffer)=>Promise<any>;
declare type BufferParseCallback = (chunk: Buffer)=>Promise<any> | any;

@@ -1258,6 +1298,15 @@ /**

/**
* Crates an instance of MultiStream with the specified stream list
* @param streams the list of readable streams (other
* objects will be filtered out!)
* @param options Optional options for the super object. ;)
* An object consisting of multiple streams than can be refined or muxed.
*
* The idea behind a MultiStream is being able to mux and demux streams when needed.
*
* Usage:
* ```javascript
* new MultiStream([...streams])
* .mux();
*
* new MultiStream(function*(){ yield* streams; })
* .map(stream => stream.filter(myFilter))
* .mux();
* ```
*/

@@ -1410,3 +1459,3 @@ constructor(streams: any[] | AsyncGenerator<Readable> | Generator<Readable>, options?: object);

*/
declare type FlatMapCallback = (chunk: any)=>Promise<Iterable<any>> | Iterable<any>;
declare type FlatMapCallback = (chunk: any)=>AsyncGenerator<any, void, any> | Promise<Iterable<any>> | Iterable<any>;

@@ -1466,3 +1515,3 @@ /**

*/
declare type ValueOfCallback = (chunk: any)=>Promise<number>;
declare type ValueOfCallback = (chunk: any)=>Promise<number> | number;

@@ -1486,4 +1535,5 @@ /**

/**
* Creates an instance of NumberStream.
* @param options
* Simple scramjet stream that by default contains numbers or other containing with `valueOf` method. The streams
* provides simple methods like `sum`, `average`. It derives from DataStream so it's still fully supporting all `map`,
* `reduce` etc.
*/

@@ -1543,3 +1593,8 @@ constructor(options: NumberStreamOptions);

/**
* Private constructor
* StreamWorker class - intended for internal use
*
* This class provides control over the subprocesses, including:
* - spawning
* - communicating
* - delivering streams
*/

@@ -1546,0 +1601,0 @@ constructor();

@@ -5,4 +5,26 @@ # Scramjet 4.x

## Scramjet 4.33.3: Fix npmignore and depdendencies update
## Scramjet 4.35.0: Fix circular depencency issue
* ce9d3ad - Lots of definition fixes on optional parameters
* 8638e70 - Depencencies update
## Scramjet 4.34.7: Fix circular depencency issue
* f08c98e - Dependencies update.
* 984f814 - Move unneeded dependency to dev
* 54db2cd - Dependencies update.
* 299b76f - Remove circular dependency
## Scramjet 4.34.4: Dependencies update & ts checking
* 9bff421 - Dependencies update.
* 02c6b21 - Add ts checks
## Scramjet 4.34.0: TS Compat: remove pipe from docs and definitions
* 6c3d516 - Fix docs
* 8451990 - TS Compat: Remove pipe from docs and ts.d
## Scramjet 4.33.5: Fix npmignore, package and depdendencies update
* a18b2c5 - Fix npmignore

@@ -9,0 +31,0 @@ * 04a40d5 - Dependencies update

@@ -5,3 +5,3 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## ~BufferStream : DataStream
## :BufferStream : DataStream
A facilitation stream created for easy splitting or parsing buffers.

@@ -25,7 +25,7 @@

**Kind**: inner class
**Kind**: static class
**Extends**: [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
**Test**: test/methods/buffer-stream-constructor.js
* [~BufferStream](#module_scramjet.BufferStream) [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [:BufferStream](#module_scramjet.BufferStream) [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [new BufferStream([opts])](#new_module_scramjet.BufferStream_new)

@@ -32,0 +32,0 @@ * [bufferStream.shift(chars, func)](#module_scramjet.BufferStream+shift) ↺

@@ -5,3 +5,3 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## ~DataStream : import("stream").PassThrough
## :DataStream : import("stream").PassThrough
DataStream is the primary stream type for Scramjet. When you parse your

@@ -22,7 +22,7 @@ stream, just pipe it you can then perform calculations on the data objects

**Kind**: inner class
**Kind**: static class
**Extends**: <code>import(&quot;stream&quot;).PassThrough</code>
**Test**: test/methods/data-stream-constructor.js
* [~DataStream](#module_scramjet.DataStream) <code>import(&quot;stream&quot;).PassThrough</code>
* [:DataStream](#module_scramjet.DataStream) <code>import(&quot;stream&quot;).PassThrough</code>
* [new DataStream([opts])](#new_module_scramjet.DataStream_new)

@@ -1179,8 +1179,9 @@ * [dataStream.map(func, [ClassType])](#module_scramjet.DataStream+map) ↺

.from(function* () {
while(x < 100) yield x++;
while(x < 100) yield {x: x++};
})
.each(console.log)
// 0
// 1...
// 99
// {x: 0}
// {x: 1}
// ...
// {x: 99}
```

@@ -1192,3 +1193,3 @@

| --- | --- | --- | --- |
| input | <code>Array</code> \| <code>Iterable.&lt;any&gt;</code> \| <code>AsyncGeneratorFunction</code> \| <code>GeneratorFunction</code> \| <code>AsyncFunction</code> \| <code>function</code> \| <code>string</code> \| <code>Readable</code> | | argument to be turned into new stream |
| input | <code>Array</code> \| <code>Iterable.&lt;any&gt;</code> \| <code>AsyncGeneratorFunction</code> \| <code>GeneratorFunction</code> \| <code>AsyncFunction</code> \| <code>Promise.&lt;any&gt;</code> \| <code>function</code> \| <code>string</code> \| <code>Readable</code> | | argument to be turned into new stream |
| [options] | [<code>DataStreamOptions</code>](definitions.md#module_scramjet..DataStreamOptions) \| <code>Writable</code> | <code>{}</code> | options for creation of a new stream or the target stream |

@@ -1195,0 +1196,0 @@ | ...args | <code>Array.&lt;any&gt;</code> | | additional arguments for the stream - will be passed to the function or generator |

@@ -16,5 +16,5 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## ~BufferParseCallback : Promise.<any>
## ~BufferParseCallback : Promise.<any> | any
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;any&gt;</code> - the promise should be resolved with the parsed object
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>any</code> - the promise should be resolved with the parsed object

@@ -27,9 +27,9 @@ | Param | Type | Description |

## ~MapCallback : Promise.<any> | *
## ~MapCallback : Promise.<any> | any
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>\*</code> - the mapped object
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>any</code> - the mapped object
| Param | Type | Description |
| --- | --- | --- |
| chunk | <code>\*</code> | the chunk to be mapped |
| chunk | <code>any</code> | the chunk to be mapped |

@@ -44,13 +44,13 @@ <a name="module_scramjet..FilterCallback"></a>

| --- | --- | --- |
| chunk | <code>\*</code> | the chunk to be filtered or not |
| chunk | <code>any</code> | the chunk to be filtered or not |
<a name="module_scramjet..ReduceCallback"></a>
## ~ReduceCallback : Promise.<*> | *
## ~ReduceCallback : Promise.<any> | any
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;\*&gt;</code> \| <code>\*</code> - accumulator for the next pass
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>any</code> - accumulator for the next pass
| Param | Type | Description |
| --- | --- | --- |
| accumulator | <code>\*</code> | the accumulator - the object initially passed or returned by the previous reduce operation |
| accumulator | <code>any</code> | the accumulator - the object initially passed or returned by the previous reduce operation |
| chunk | <code>object</code> | the stream chunk. |

@@ -60,4 +60,5 @@

## ~DoCallback : function ⇄
## ~DoCallback : Promise.<any> | any ⇄
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>any</code> - the outcome is discarded

@@ -70,5 +71,5 @@ | Param | Type | Description |

## ~IntoCallback : * ⇄
## ~IntoCallback : Promise.<any> | any ⇄
**Kind**: inner typedef
**Returns**: <code>\*</code> - resolution for the old stream (for flow control only)
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>any</code> - resolution for the old stream (for flow control only)

@@ -78,3 +79,3 @@ | Param | Type | Description |

| into | <code>\*</code> | stream passed to the into method |
| chunk | <code>object</code> | source stream chunk |
| chunk | <code>any</code> | source stream chunk |

@@ -102,3 +103,3 @@ <a name="module_scramjet..UseCallback"></a>

## ~ScramjetTransformCallback : * | undefined
## ~ScramjetTransformCallback : Promise.<(any|undefined)> | any | undefined
Transform async callback. The passed transform should return a new chunk, unless

@@ -111,7 +112,7 @@ the output should be filtered - if so, the transform should return `undefined`.

**Kind**: inner typedef
**Returns**: <code>\*</code> \| <code>undefined</code> - the result, undefined will be treated as filtered out.
**Returns**: <code>Promise.&lt;(any\|undefined)&gt;</code> \| <code>any</code> \| <code>undefined</code> - the result, undefined will be treated as filtered out.
| Param | Type | Description |
| --- | --- | --- |
| chunk | <code>Buffer</code> \| <code>string</code> \| <code>\*</code> | the stream chunk |
| chunk | <code>Buffer</code> \| <code>string</code> \| <code>any</code> | the stream chunk |
| encoding | <code>string</code> | encoding of the chunk |

@@ -121,10 +122,11 @@

## ~ScramjetWriteCallback : function
## ~ScramjetWriteCallback : Promise.<void> | void
Write async callback. Await your async write and resolve.
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;void&gt;</code> \| <code>void</code> - should resolve when the write ends
| Param | Type | Description |
| --- | --- | --- |
| chunk | <code>Buffer</code> \| <code>string</code> \| <code>\*</code> | the stream chunk |
| chunk | <code>Buffer</code> \| <code>string</code> \| <code>any</code> | the stream chunk |
| encoding | <code>string</code> | encoding of the chunk |

@@ -134,7 +136,7 @@

## ~ScramjetReadCallback : Array.<*>
## ~ScramjetReadCallback : Array.<any> | Promise.<Array.<any>>
Read async callback. Simply await your async operations and return the result as array.
**Kind**: inner typedef
**Returns**: <code>Array.&lt;\*&gt;</code> - the read chunk.
**Returns**: <code>Array.&lt;any&gt;</code> \| <code>Promise.&lt;Array.&lt;any&gt;&gt;</code> - the read chunk.

@@ -212,5 +214,5 @@ | Param | Type | Description |

## ~FlatMapCallback : Promise.<Iterable.<any>> | Iterable.<any>
## ~FlatMapCallback : AsyncGenerator.<any, void, any> | Promise.<Iterable.<any>> | Iterable.<any>
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;Iterable.&lt;any&gt;&gt;</code> \| <code>Iterable.&lt;any&gt;</code> - promise to be resolved when chunk has been processed
**Returns**: <code>AsyncGenerator.&lt;any, void, any&gt;</code> \| <code>Promise.&lt;Iterable.&lt;any&gt;&gt;</code> \| <code>Iterable.&lt;any&gt;</code> - promise to be resolved when chunk has been processed

@@ -335,5 +337,5 @@ | Param | Type | Description |

## ~ValueOfCallback : Promise.<number>
## ~ValueOfCallback : Promise.<number> | number
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;number&gt;</code> - value of the object
**Returns**: <code>Promise.&lt;number&gt;</code> \| <code>number</code> - value of the object

@@ -368,5 +370,5 @@ | Param | Type | Description |

## ~ParseCallback : Promise.<any>
## ~ParseCallback : Promise.<any> | any
**Kind**: inner typedef
**Returns**: <code>Promise.&lt;any&gt;</code> - the promise should be resolved with the parsed object
**Returns**: <code>Promise.&lt;any&gt;</code> \| <code>any</code> - the promise should be resolved with the parsed object

@@ -373,0 +375,0 @@ | Param | Type | Description |

@@ -5,3 +5,3 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## ~MultiStream
## :MultiStream
An object consisting of multiple streams than can be refined or muxed.

@@ -21,6 +21,6 @@

**Kind**: inner class
**Kind**: static class
**Test**: test/methods/multi-stream-constructor.js
* [~MultiStream](#module_scramjet.MultiStream)
* [:MultiStream](#module_scramjet.MultiStream)
* [new MultiStream(streams, [options])](#new_module_scramjet.MultiStream_new)

@@ -49,3 +49,3 @@ * [multiStream.streams](#module_scramjet.MultiStream+streams) <code>Array</code>

| --- | --- | --- | --- |
| streams | <code>Array.&lt;stream.Readable&gt;</code> \| <code>AsyncGenerator.&lt;Readable&gt;</code> \| <code>Generator.&lt;Readable&gt;</code> | | the list of readable streams (other objects will be filtered out!) |
| streams | <code>Array.&lt;stream.Readable&gt;</code> \| <code>AsyncGenerator.&lt;Readable&gt;</code> \| <code>Generator.&lt;Readable&gt;</code> | | the list of readable streams (other objects will be filtered out!) |
| [options] | <code>object</code> | <code>{}</code> | Optional options for the super object. ;) |

@@ -52,0 +52,0 @@

@@ -5,3 +5,3 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## ~StreamWorker
## :StreamWorker
StreamWorker class - intended for internal use

@@ -14,6 +14,6 @@

**Kind**: inner class
**Kind**: static class
**Internal**:
* [~StreamWorker](#module_scramjet.StreamWorker)
* [:StreamWorker](#module_scramjet.StreamWorker)
* [new StreamWorker()](#new_module_scramjet.StreamWorker_new)

@@ -20,0 +20,0 @@ * [streamWorker.spawn()](#module_scramjet.StreamWorker+spawn) ⇄ [<code>StreamWorker</code>](stream-worker.md#module_scramjet.StreamWorker)

@@ -5,3 +5,3 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## ~StringStream : DataStream
## :StringStream : DataStream
A stream of string objects for further transformation on top of DataStream.

@@ -11,11 +11,14 @@

```javascript
StringStream.fromString()
```js
StringStream.from(async () => (await fetch('https://example.com/data/article.txt')).text())
.lines()
.append("\r\n")
.pipe(fs.createWriteStream('./path/to/file.txt'))
```
**Kind**: inner class
**Kind**: static class
**Extends**: [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
**Test**: test/methods/string-stream-constructor.js
**Scope**: public
* [~StringStream](#module_scramjet.StringStream) [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [:StringStream](#module_scramjet.StringStream) [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [new StringStream([encoding], [options])](#new_module_scramjet.StringStream_new)

@@ -26,3 +29,3 @@ * [stringStream.shift(bytes, func)](#module_scramjet.StringStream+shift) ↺

* [stringStream.toBufferStream()](#module_scramjet.StringStream+toBufferStream) ↺ [<code>BufferStream</code>](buffer-stream.md#module_scramjet.BufferStream)
* [stringStream.parse(parser, StreamClass)](#module_scramjet.StringStream+parse) ↺ [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [stringStream.parse(parser, [StreamClass])](#module_scramjet.StringStream+parse) ↺ [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [stringStream.toDataStream()](#module_scramjet.StringStream+toDataStream)

@@ -111,3 +114,3 @@ * [stringStream.lines([eol])](#module_scramjet.StringStream+lines) ↺

### stringStream.parse(parser, StreamClass) : DataStream ↺
### stringStream.parse(parser, [StreamClass]) : DataStream ↺
Parses every string to object

@@ -126,3 +129,3 @@

| parser | [<code>ParseCallback</code>](definitions.md#module_scramjet..ParseCallback) | The transform function |
| StreamClass | <code>function</code> | the output stream class to return |
| [StreamClass] | <code>function</code> | the output stream class to return |

@@ -146,3 +149,3 @@ <a name="module_scramjet.StringStream+toDataStream"></a>

| --- | --- | --- | --- |
| [eol] | <code>string</code> | <code>&quot;/\\r?\\n/&quot;</code> | End of line string or regex |
| [eol] | <code>string</code> \| <code>RegExp</code> | <code>&quot;/\\r?\\n/&quot;</code> | End of line string or regex |

@@ -188,3 +191,3 @@ <a name="module_scramjet.StringStream+JSONParse"></a>

| --- | --- | --- |
| param | <code>function</code> \| <code>string</code> | the argument to append. If function passed then it will be called and resolved and the resolution will be appended. |
| param | <code>ThenFunction</code> \| <code>string</code> | the argument to append. If function passed then it will be called and resolved and the resolution will be appended. |

@@ -202,3 +205,3 @@ <a name="module_scramjet.StringStream+prepend"></a>

| --- | --- | --- |
| param | <code>function</code> \| <code>string</code> | the argument to prepend. If function passed then it will be called and resolved and the resolution will be prepended. |
| param | <code>ThenFunction</code> \| <code>string</code> | the argument to prepend. If function passed then it will be called and resolved and the resolution will be prepended. |

@@ -205,0 +208,0 @@ <a name="module_scramjet.StringStream+exec"></a>

@@ -5,3 +5,3 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

## :WindowStream : DataStream
## :WindowStream : NumberStream
A stream for moving window calculation with some simple methods.

@@ -13,5 +13,5 @@

**Kind**: static class
**Extends**: [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
**Extends**: [<code>NumberStream</code>](number-stream.md#module_scramjet.NumberStream)
* [:WindowStream](#module_scramjet.WindowStream) [<code>DataStream</code>](data-stream.md#module_scramjet.DataStream)
* [:WindowStream](#module_scramjet.WindowStream) [<code>NumberStream</code>](number-stream.md#module_scramjet.NumberStream)
* [windowStream.sum([valueOf])](#module_scramjet.WindowStream+sum) ↺ [<code>NumberStream</code>](number-stream.md#module_scramjet.NumberStream)

@@ -18,0 +18,0 @@ * [windowStream.avg([valueOf])](#module_scramjet.WindowStream+avg) ↺ [<code>NumberStream</code>](number-stream.md#module_scramjet.NumberStream)

@@ -448,3 +448,3 @@ const scramjet = require("./");

* @param {*} chunk the chunk from the original stream
* @returns {Promise<Iterable<any>>|Iterable<any>} promise to be resolved when chunk has been processed
* @returns {AsyncGenerator<any, void, any>|Promise<Iterable<any>>|Iterable<any>} promise to be resolved when chunk has been processed
*/

@@ -451,0 +451,0 @@

@@ -17,3 +17,3 @@ const {DataStream} = require("./");

* @param {*} chunk stream object
* @returns {Promise<number>} value of the object
* @returns {Promise<number>|number} value of the object
*/

@@ -20,0 +20,0 @@

@@ -17,3 +17,3 @@ const {DataStream} = require("./");

* @memberof module:scramjet.StringStream#
* @param {string} [eol=/\r?\n/] End of line string or regex
* @param {string|RegExp} [eol=/\r?\n/] End of line string or regex
*

@@ -83,3 +83,3 @@ * @test test/methods/string-stream-split.js

* @memberof module:scramjet.StringStream#
* @param {Function|string} param the argument to append. If function passed then it will be called and resolved and the resolution will be appended.
* @param {ThenFunction|string} param the argument to append. If function passed then it will be called and resolved and the resolution will be appended.
*

@@ -97,3 +97,3 @@ * @test test/methods/string-stream-append.js

* @memberof module:scramjet.StringStream#
* @param {Function|string} param the argument to prepend. If function passed then it will be called and resolved
* @param {ThenFunction|string} param the argument to prepend. If function passed then it will be called and resolved
* and the resolution will be prepended.

@@ -154,6 +154,5 @@ *

});
proc.on("exit", async code => {
if (code > 0) {
const error = new Error(`Non-zero exitcode (${code}) returned from command "${resolvedCommand}"`);
error.exitCode = code;
proc.on("exit", async exitCode => {
if (exitCode > 0) {
const error = Object.assign(new Error(`Non-zero exitcode (${exitCode}) returned from command "${resolvedCommand}"`), {exitCode});
await out.raise(error);

@@ -160,0 +159,0 @@ }

@@ -10,3 +10,3 @@ const {NumberStream} = require("./");

* @memberof module:scramjet.
* @extends DataStream
* @extends NumberStream
*/

@@ -13,0 +13,0 @@ class WindowStream extends NumberStream {

{
"name": "scramjet",
"version": "4.34.7",
"version": "4.35.1",
"description": "Lightweight and real-time data functional stream programming framework like event-stream, written in ES6 using async await with multi-threading and typescript support",

@@ -69,8 +69,8 @@ "main": "lib/index.js",

"@otris/jsdoc-tsd": "^2.0.0",
"@types/node": "^14.6.4",
"@types/node": "^14.11.2",
"check-dts": "^0.3.3",
"decache": "^4.6.0",
"dmd": "^5.0.2",
"eslint": "^7.8.1",
"eslint-config-scramjet": "^2.0.1",
"eslint": "^7.10.0",
"eslint-config-scramjet": "^3.0.0",
"fancy-log": "^1.3.3",

@@ -81,19 +81,18 @@ "gulp": "^4.0.2",

"gulp-shell": "^0.8.0",
"jsdoc": "^3.6.5",
"jsdoc": "^3.6.6",
"jsdoc-api": "^6.0.0",
"jsdoc-parse": "^5.0.0",
"nodeunit-tape-compat": "^1.3.56",
"node-fetch": "^2.6.1",
"nodeunit-tape-compat": "^1.3.59",
"replace-in-file": "^6.1.0",
"request": "^2.88.2",
"request-promise-native": "^1.0.9",
"shelljs": "^0.8.4",
"tape": "^5.0.1",
"through2": "^4.0.2",
"vinyl": "^2.2.0"
"vinyl": "^2.2.1"
},
"dependencies": {
"papaparse": "^5.3.0",
"rereadable-stream": "^1.3.38",
"scramjet-core": "^4.29.2"
"rereadable-stream": "^1.4.1",
"scramjet-core": "^4.31.0"
}
}

@@ -33,21 +33,16 @@ ![Scramjet Logo](https://signicode.com/scramjet-logo-light.svg)

```javascript
const request = require("request");
const rp = require("request-promise-native");
const fetch = require("node-fetch");
const get = async (url, options = {}) => (await fetch(url, options)).json;
const { StringStream } = require("scramjet");
StringStream.from( // fetch your API to a scramjet stream
request("https://api.example.org/v1/shows/list")
() => get("https://api.example.org/v1/shows/list")
)
.setOptions({maxParallel: 4}) // set your options
.lines() // split the stream by line
.parse(theirShow => { // parse strings to data
return {
id: theirShow.id,
title: theirShow.name,
url: theirShow.url
};
.parse(line => { // parse strings to data
const [id, title, url] = line.split(",");
return { id, title, url };
})
.map(async myShow => rp({ // use asynchronous mapping (for example send requests)
method: "POST",
simple: true,
.map(async myShow => get({ // use asynchronous mapping (for example send requests)
uri: `http://api.local/set/${myShow.id}`,

@@ -247,29 +242,3 @@ body: JSON.stringify(myShow)

### :NumberStream
Simple scramjet stream that by default contains numbers or other containing with `valueOf` method. The streams
provides simple methods like `sum`, `average`. It derives from DataStream so it's still fully supporting all `map`,
`reduce` etc.
[Detailed :NumberStream docs here](docs/number-stream.md)
**Most popular methods:**
* `new NumberStream(options)` - Creates an instance of NumberStream.
* [`numberStream.sum() : Promise.<number> | any ⇄`](docs/number-stream.md#module_scramjet.NumberStream+sum) - Calculates the sum of all items in the stream.
* [`numberStream.avg() : Promise.<number> | any ⇄`](docs/number-stream.md#module_scramjet.NumberStream+avg) - Calculates the sum of all items in the stream.
### :WindowStream
A stream for moving window calculation with some simple methods.
In essence it's a stream of Array's containing a list of items - a window.
It's best used when created by the `DataStream..window`` method.
[Detailed :WindowStream docs here](docs/window-stream.md)
**Most popular methods:**
* [`windowStream.sum([valueOf]) : NumberStream ↺`](docs/window-stream.md#module_scramjet.WindowStream+sum) - Calculates moving sum of items, the output NumberStream will contain the moving sum.
* [`windowStream.avg([valueOf]) : NumberStream ↺`](docs/window-stream.md#module_scramjet.WindowStream+avg) - Calculates the moving average of the window and returns the NumberStream
### ~DataStream
### :DataStream
DataStream is the primary stream type for Scramjet. When you parse your

@@ -290,3 +259,3 @@ stream, just pipe it you can then perform calculations on the data objects

[Detailed ~DataStream docs here](docs/data-stream.md)
[Detailed :DataStream docs here](docs/data-stream.md)

@@ -367,3 +336,3 @@ **Most popular methods:**

### ~StringStream
### :StringStream
A stream of string objects for further transformation on top of DataStream.

@@ -373,7 +342,10 @@

```javascript
StringStream.fromString()
```js
StringStream.from(async () => (await fetch('https://example.com/data/article.txt')).text())
.lines()
.append("\r\n")
.pipe(fs.createWriteStream('./path/to/file.txt'))
```
[Detailed ~StringStream docs here](docs/string-stream.md)
[Detailed :StringStream docs here](docs/string-stream.md)

@@ -387,3 +359,3 @@ **Most popular methods:**

* [`stringStream.toBufferStream() : BufferStream ↺`](docs/string-stream.md#module_scramjet.StringStream+toBufferStream) - Transforms the StringStream to BufferStream
* [`stringStream.parse(parser, StreamClass) : DataStream ↺`](docs/string-stream.md#module_scramjet.StringStream+parse) - Parses every string to object
* [`stringStream.parse(parser, [StreamClass]) : DataStream ↺`](docs/string-stream.md#module_scramjet.StringStream+parse) - Parses every string to object
* [`stringStream.toDataStream()`](docs/string-stream.md#module_scramjet.StringStream+toDataStream) - Alias for {@link StringStream#parse}

@@ -401,3 +373,3 @@ * [`stringStream.lines([eol]) ↺`](docs/string-stream.md#module_scramjet.StringStream+lines) - Splits the string stream by the specified regexp or string

### ~BufferStream
### :BufferStream
A facilitation stream created for easy splitting or parsing buffers.

@@ -421,3 +393,3 @@

[Detailed ~BufferStream docs here](docs/buffer-stream.md)
[Detailed :BufferStream docs here](docs/buffer-stream.md)

@@ -435,3 +407,3 @@ **Most popular methods:**

### ~MultiStream
### :MultiStream
An object consisting of multiple streams than can be refined or muxed.

@@ -451,3 +423,3 @@

[Detailed ~MultiStream docs here](docs/multi-stream.md)
[Detailed :MultiStream docs here](docs/multi-stream.md)

@@ -471,3 +443,29 @@ **Most popular methods:**

### ~StreamWorker
### :NumberStream
Simple scramjet stream that by default contains numbers or other containing with `valueOf` method. The streams
provides simple methods like `sum`, `average`. It derives from DataStream so it's still fully supporting all `map`,
`reduce` etc.
[Detailed :NumberStream docs here](docs/number-stream.md)
**Most popular methods:**
* `new NumberStream(options)` - Creates an instance of NumberStream.
* [`numberStream.sum() : Promise.<number> | any ⇄`](docs/number-stream.md#module_scramjet.NumberStream+sum) - Calculates the sum of all items in the stream.
* [`numberStream.avg() : Promise.<number> | any ⇄`](docs/number-stream.md#module_scramjet.NumberStream+avg) - Calculates the sum of all items in the stream.
### :WindowStream
A stream for moving window calculation with some simple methods.
In essence it's a stream of Array's containing a list of items - a window.
It's best used when created by the `DataStream..window`` method.
[Detailed :WindowStream docs here](docs/window-stream.md)
**Most popular methods:**
* [`windowStream.sum([valueOf]) : NumberStream ↺`](docs/window-stream.md#module_scramjet.WindowStream+sum) - Calculates moving sum of items, the output NumberStream will contain the moving sum.
* [`windowStream.avg([valueOf]) : NumberStream ↺`](docs/window-stream.md#module_scramjet.WindowStream+avg) - Calculates the moving average of the window and returns the NumberStream
### :StreamWorker
StreamWorker class - intended for internal use

@@ -480,3 +478,3 @@

[Detailed ~StreamWorker docs here](docs/stream-worker.md)
[Detailed :StreamWorker docs here](docs/stream-worker.md)

@@ -483,0 +481,0 @@ **Most popular methods:**

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc