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

stream-executor

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-executor - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

lib/executors/__interfaces__/constructor.d.ts

1

lib/executors/__interfaces__/base.executor.d.ts
export interface BaseExecutor {
stream: (...args: any[]) => Omit<this, 'stream'>;
execute: (...args: any[]) => any;
}
export * from './base.executor';
export * from './constructor';

2

lib/executors/batch.executor.d.ts

@@ -7,4 +7,4 @@ import { BaseExecutor } from './__interfaces__';

constructor(initialValue: T);
stream<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<T, B>, act3?: Action<T, C>, act4?: Action<T, D>, act5?: Action<T, E>, act6?: Action<T, F>, act7?: Action<T, G>, act8?: Action<T, H>, act9?: Action<T, I>, act10?: Action<T, J>): this;
stream<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<T, B>, act3?: Action<T, C>, act4?: Action<T, D>, act5?: Action<T, E>, act6?: Action<T, F>, act7?: Action<T, G>, act8?: Action<T, H>, act9?: Action<T, I>, act10?: Action<T, J>): Omit<this, 'stream'>;
execute(onError?: (error: any) => any): void;
}

@@ -8,4 +8,4 @@ import { BaseExecutor } from './__interfaces__';

constructor(initialValue: T);
stream<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<A, B>, act3?: Action<B, C>, act4?: Action<C, D>, act5?: Action<D, E>, act6?: Action<E, F>, act7?: Action<F, G>, act8?: Action<G, H>, act9?: Action<H, I>, act10?: Action<I, J>): Pick<this, Exclude<keyof this, "stream">>;
asAsync(): Pick<this, "execute">;
stream<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<A, B>, act3?: Action<B, C>, act4?: Action<C, D>, act5?: Action<D, E>, act6?: Action<E, F>, act7?: Action<F, G>, act8?: Action<G, H>, act9?: Action<H, I>, act10?: Action<I, J>): Omit<this, 'stream'>;
asAsync(): Pick<this, 'execute'>;
execute(onError?: (error: any) => any): PromiseOr<any>;

@@ -12,0 +12,0 @@ private _execute;

import { Action } from '../types';
import { ChainExecutor } from './chain.executor';
import { BatchExecutor } from './batch.executor';
import { Constructor, BaseExecutor } from './__interfaces__';
export declare class StreamExecutorFacade<T> {
private _initialValue;
constructor(initialValue: T);
private _chainClass;
private _batchClass;
constructor(initialValue: T, option: {
chainClass?: Constructor<BaseExecutor>;
batchClass?: Constructor<BaseExecutor>;
});
/**

@@ -23,3 +27,3 @@ * sequential execute.

*/
chain<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<A, B>, act3?: Action<B, C>, act4?: Action<C, D>, act5?: Action<D, E>, act6?: Action<E, F>, act7?: Action<F, G>, act8?: Action<G, H>, act9?: Action<H, I>, act10?: Action<I, J>): Pick<Pick<ChainExecutor<T>, "execute" | "asAsync">, "execute" | "asAsync">;
chain<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<A, B>, act3?: Action<B, C>, act4?: Action<C, D>, act5?: Action<D, E>, act6?: Action<E, F>, act7?: Action<F, G>, act8?: Action<G, H>, act9?: Action<H, I>, act10?: Action<I, J>): Pick<Pick<BaseExecutor, "execute">, "execute">;
/**

@@ -39,9 +43,20 @@ * batch execute, like `when` in Kotlin.

*/
batch<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<T, B>, act3?: Action<T, C>, act4?: Action<T, D>, act5?: Action<T, E>, act6?: Action<T, F>, act7?: Action<T, G>, act8?: Action<T, H>, act9?: Action<T, I>, act10?: Action<T, J>): Pick<BatchExecutor<T>, "execute">;
batch<A, B, C, D, E, F, G, H, I, J>(act1: Action<T, A>, act2?: Action<T, B>, act3?: Action<T, C>, act4?: Action<T, D>, act5?: Action<T, E>, act6?: Action<T, F>, act7?: Action<T, G>, act8?: Action<T, H>, act9?: Action<T, I>, act10?: Action<T, J>): Pick<Pick<BaseExecutor, "execute">, "execute">;
private _create;
}
/**
* create streamer, initialValue is shallow copied.
* Use `deepCopy` in this library if you'd like to do deep copy
*
*
* Use `deepCopy` in this library if you'd like to do deep copy.
*
*
* Set `option.chainClass` or `option.batchClass` if you would change execution process.
* - https://github.com/nor-ko-hi-jp/stream-executor/blob/master/README.md#6-replace-chain-or-batch-executor
* @param initialValue T
* @param option: { chainClass?: { new (...args: any[]): BaseExecutor }, batchClass?: { new (...args: any[]): BaseExecutor } }
*/
export declare const createStream: <T>(initialValue: T) => StreamExecutorFacade<T>;
export declare const createStream: <T>(initialValue: T, option?: {
chainClass?: Constructor<BaseExecutor> | undefined;
batchClass?: Constructor<BaseExecutor> | undefined;
}) => StreamExecutorFacade<T>;

@@ -6,4 +6,6 @@ "use strict";

class StreamExecutorFacade {
constructor(initialValue) {
constructor(initialValue, option) {
this._initialValue = initialValue;
this._chainClass = option.chainClass ? option.chainClass : chain_executor_1.ChainExecutor;
this._batchClass = option.batchClass ? option.batchClass : batch_executor_1.BatchExecutor;
}

@@ -27,3 +29,3 @@ /**

chain(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10) {
const executor = new chain_executor_1.ChainExecutor(this._initialValue).stream(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10);
const executor = this._create('chain', this._initialValue).stream(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10);
return executor;

@@ -46,5 +48,11 @@ }

batch(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10) {
const executor = new batch_executor_1.BatchExecutor(this._initialValue).stream(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10);
const executor = this._create('batch', this._initialValue).stream(act1, act2, act3, act4, act5, act6, act7, act8, act9, act10);
return executor;
}
_create(type, ...args) {
const instance = type === 'chain'
? new this._chainClass(...args)
: new this._batchClass(...args);
return instance;
}
}

@@ -54,5 +62,12 @@ exports.StreamExecutorFacade = StreamExecutorFacade;

* create streamer, initialValue is shallow copied.
* Use `deepCopy` in this library if you'd like to do deep copy
*
*
* Use `deepCopy` in this library if you'd like to do deep copy.
*
*
* Set `option.chainClass` or `option.batchClass` if you would change execution process.
* - https://github.com/nor-ko-hi-jp/stream-executor/blob/master/README.md#6-replace-chain-or-batch-executor
* @param initialValue T
* @param option: { chainClass?: { new (...args: any[]): BaseExecutor }, batchClass?: { new (...args: any[]): BaseExecutor } }
*/
exports.createStream = (initialValue) => new StreamExecutorFacade(initialValue);
exports.createStream = (initialValue, option = {}) => new StreamExecutorFacade(initialValue, option);
export * from './executor.facade';
export * from './batch.executor';
export * from './chain.executor';
export * from './helpers';
export * from './__interfaces__';

@@ -7,2 +7,4 @@ "use strict";

__export(require("./executor.facade"));
__export(require("./batch.executor"));
__export(require("./chain.executor"));
__export(require("./helpers"));
{
"name": "stream-executor",
"version": "1.2.0",
"version": "1.3.0",
"description": "functional stream programming",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -123,3 +123,3 @@ # stream-executor

# Important
## 1. about `createStream`
## 1. About `createStream`
- The argument of createStream is not deep copied. use `deepCopy` method if you'd like to do deep copy, please.

@@ -142,4 +142,4 @@ ```ts

```
## 2. about `deepCopy`
- getter and function in object are removed.
## 2. About `deepCopy`
- Getter and function in object are removed.
```ts

@@ -166,4 +166,4 @@ import { createStream, tap, deepCopy } from 'stream-executor'

```
## 3. about `createStream().chain()`:
- further process is not called if `undefined` returned
## 3. About `createStream().chain()`:
- Further process is not called if `undefined` returned
```ts

@@ -181,4 +181,4 @@ import { createStream, tap, filter, map } from 'stream-executor'

## 4. use asynchronous execution in `createStream().chain()`:
- call `asAsync` method before `execute` method
## 4. Use asynchronous execution in `createStream().chain()`:
- Call `asAsync` method before `execute` method
```ts

@@ -197,4 +197,4 @@ import { createStream, tap, map } from 'stream-executor'

## 5. abount the arguments of execute()
- set the arguments of execute method if you'd like to customize error handling, please
## 5. Abount the arguments of execute()
- Set the arguments of execute method if you'd like to customize error handling, please
```ts

@@ -213,2 +213,34 @@ let error: any

## 6. Replace `chain` or `batch` executor
- Set `option.chainClass` or `option.batchClass` if you would change execution process, please
```ts
import { BaseExecutor, createStream } from 'stream-executor'
class MockChainExecutor implements BaseExecutor {
stream(...args: any[]) {
return this
}
execute() {
console.log('MockChainExecutor called')
}
}
class MockBatchExecutor implements BaseExecutor {
stream(...args: any[]) {
return this
}
execute() {
console.log('MockBatchExecutor called')
}
}
createStream(1, { chainClass: MockChainExecutor })
.chain((it) => it)
.execute() // 'MockChainExecutor called'
createStream(1, { batchClass: MockBatchExecutor })
.batch((it) => it)
.execute() // 'MockBatchExecutor called'
```
# Utils

@@ -215,0 +247,0 @@ ## helper methods and those descriptions in createStream are

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