evg_observable 1.14.55 → 1.14.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "evg_observable",
3
- "version": "1.14.55",
3
+ "version": "1.14.56",
4
4
  "description": "Alternative fast and light library version - observable.",
5
5
  "main": "src/outLib/index.js",
6
6
  "directories": {
@@ -1 +1 @@
1
- (()=>{"use strict";const s=(s,e)=>s.order>e.order?1:s.order<e.order?-1:0,e=(s,e)=>s.order>e.order?-1:s.order<e.order?1:0;function i(s,e){const i=s.indexOf(e);return-1!==i&&(s[i]=s[s.length-1],s.length=s.length-1,!0)}function t(s){return"next"in s?e=>s.next(e):s}class r{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isNeedUnsubscribe:!1,isAvailable:!1,payload:null}}setOnce(){const s=this.pipeData;return this.chainHandlers.push((()=>{this.listener(s.payload),s.isNeedUnsubscribe=!0})),this}unsubscribeByNegative(s){const e=this.pipeData;return this.chainHandlers.push((()=>{e.isAvailable=!0,s(e.payload)||(e.isNeedUnsubscribe=!0)})),this}unsubscribeByPositive(s){const e=this.pipeData;return this.chainHandlers.push((()=>{e.isAvailable=!0,s(e.payload)&&(e.isNeedUnsubscribe=!0)})),this}unsubscribeBy(s){return this.unsubscribeByPositive(s)}emitByNegative(s){const e=this.pipeData;return this.chainHandlers.push((()=>{s(e.payload)||(e.isAvailable=!0)})),this}emitByPositive(s){const e=this.pipeData;return this.chainHandlers.push((()=>{s(e.payload)&&(e.isAvailable=!0)})),this}refine(s){return this.emitByPositive(s)}pushRefiners(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.emitByPositive(s[e]);return this}emitMatch(s){const e=this.pipeData;return this.chainHandlers.push((()=>{s(e.payload)==e.payload&&(e.isAvailable=!0)})),this}switch(){return new n(this)}then(s){const e=this.pipeData;return this.chainHandlers.push((()=>{e.payload=s(e.payload),e.isAvailable=!0})),this}serialize(){const s=this.pipeData;return this.chainHandlers.push((()=>{s.payload=JSON.stringify(s.payload),s.isAvailable=!0})),this}deserialize(){const s=this.pipeData;return this.chainHandlers.push((()=>{s.payload=JSON.parse(s.payload),s.isAvailable=!0})),this}processChain(s){const e=this.chainHandlers,i=this.pipeData;for(let s=0;s<e.length;s++){if(i.isNeedUnsubscribe=!1,i.isAvailable=!1,e[s](),i.isNeedUnsubscribe)return this.unsubscribe();if(!i.isAvailable)return;if(i.isBreakChain)break}return s(i.payload)}}class n{constructor(s){this.pipe=s,this.caseCounter=s.chainHandlers.length?s.chainHandlers.length:0}subscribe(s,e){return this.pipe.subscribe(s,e)}case(s){this.caseCounter++;const e=this.caseCounter,i=this.pipe.pipeData,t=this.pipe.chainHandlers;return t.push((()=>{i.isAvailable=!0,s(i.payload)&&(i.isBreakChain=!0),e!==t.length||i.isBreakChain||(i.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.case(s[e]);return this}}class h extends r{constructor(s,e){super(),this.errorHandler=(s,e)=>{console.log(`(Unit of SubscribeObject).send(${s}) ERROR:`,e)},this._order=0,this.isPaused=!1,this.isPipe=!1,this.observable=s,this.isPipe=!!e}subscribe(s,e){return this.listener=function(s){if(Array.isArray(s)){const e=[];for(let i=0;i<s.length;i++)e.push(t(s[i]));return s=>{for(let i=0;i<e.length;i++)e[i](s)}}return t(s)}(s),e&&(this.errorHandler=e),this}unsubscribe(){this.observable&&(this.observable.unSubscribe(this),this.observable=null,this.listener=null,this.chainHandlers.length=0)}send(s){try{this.pipeData.payload=s,this.pipeData.isBreakChain=!1,this.processValue(s)}catch(e){this.errorHandler(s,e)}}resume(){this.isPaused=!1}pause(){this.isPaused=!0}get order(){return this._order}set order(s){this._order=s}processValue(s){const e=this.listener;return e&&this.observable?this.isPaused?void 0:this.isPipe?this.processChain(e):e(s):this.unsubscribe()}}class a{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isAvailable:!1,payload:null},this.response={isOK:!1,payload:void 0}}get isEmpty(){return!this.chainHandlers.length}filter(s){const e=this.pipeData;return this.chainHandlers.push((()=>{s(e.payload)&&(e.isAvailable=!0)})),this}pushFilters(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.filter(s[e]);return this}switch(){return new l(this)}processChain(s){const e=this.chainHandlers,i=this.pipeData,t=this.response;t.isOK=!1,t.payload=void 0,i.payload=s,i.isBreakChain=!1;try{for(let s=0;s<e.length;s++){if(i.isAvailable=!1,e[s](),!i.isAvailable)return t;if(i.isBreakChain)break}}catch(s){return this.errorHandler?this.errorHandler(s,"Filter.processChain ERROR:"):console.log("Filter.processChain ERROR:",s),t}return t.isOK=!0,t.payload=i.payload,t}addErrorHandler(s){this.errorHandler=s}}class l{constructor(s){this.pipe=s,this.caseCounter=s.chainHandlers.length?s.chainHandlers.length:0}case(s){this.caseCounter++;const e=this.caseCounter,i=this.pipe.pipeData,t=this.pipe.chainHandlers;return t.push((()=>{i.isAvailable=!0,s(i.payload)&&(i.isBreakChain=!0),e!==t.length||i.isBreakChain||(i.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.case(s[e]);return this}}class o{constructor(s){this.value=s,this.listeners=[],this._isEnable=!0,this._isDestroyed=!1,this.isNextProcess=!1,this.listenersForUnsubscribe=[],this.filterCase=new a}addFilter(s){return s&&this.filterCase.addErrorHandler(s),this.filterCase}disable(){this._isEnable=!1}enable(){this._isEnable=!0}get isEnable(){return this._isEnable}next(s){if(!this._isDestroyed&&this._isEnable&&(this.filterCase.isEmpty||this.filterCase.processChain(s).isOK)){this.isNextProcess=!0,this.value=s;for(let e=0;e<this.listeners.length;e++)this.listeners[e].send(s);this.isNextProcess=!1,this.listenersForUnsubscribe.length&&this.handleListenersForUnsubscribe()}}stream(s){if(!this._isDestroyed&&this._isEnable)for(let e=0;e<s.length;e++)this.next(s[e])}handleListenersForUnsubscribe(){const s=this.listenersForUnsubscribe.length;for(let e=0;e<s;e++)this.unSubscribe(this.listenersForUnsubscribe[e]);this.listenersForUnsubscribe.length=0}unSubscribe(s){this._isDestroyed||(this.isNextProcess&&s?this.listenersForUnsubscribe.push(s):this.listeners&&i(this.listeners,s))}destroy(){this.value=null,this.unsubscribeAll(),this.listeners=null,this._isDestroyed=!0}unsubscribeAll(){this._isDestroyed||(this.listeners.length=0)}getValue(){if(!this._isDestroyed)return this.value}size(){return this._isDestroyed?0:this.listeners.length}subscribe(s,e){if(!this.isSubsValid(s))return;const i=new h(this,!1);return this.addObserver(i,s,e),i}addObserver(s,e,i){s.subscribe(e,i),this.listeners.push(s)}isSubsValid(s){return!this._isDestroyed&&!!s}pipe(){if(this._isDestroyed)return;const s=new h(this,!0);return this.listeners.push(s),s}get isDestroyed(){return this._isDestroyed}}class u extends h{constructor(s,e){super(s,e)}get order(){return this._order}set order(s){!this.observable||this.observable&&this.observable.isDestroyed?this._order=void 0:(this._order=s,this.observable.sortByOrder())}subscribe(s,e){return super.subscribe(s,e),this}setOnce(){return super.setOnce()}unsubscribeByNegative(s){return super.unsubscribeByNegative(s)}unsubscribeByPositive(s){return super.unsubscribeByPositive(s)}emitByNegative(s){return super.emitByNegative(s)}emitByPositive(s){return super.emitByPositive(s)}emitMatch(s){return super.emitMatch(s)}}const c=window;c.Observable=o,c.Collector=class{constructor(){this.list=[],this._isDestroyed=!1}collect(...s){this._isDestroyed||this.list.push(...s)}unsubscribe(s){this._isDestroyed||(s?.unsubscribe(),i(this.list,s))}unsubscribeAll(){if(!this._isDestroyed)for(;this.list.length>0;)this.unsubscribe(this.list.pop())}size(){return this._isDestroyed?0:this.list.length}destroy(){this.unsubscribeAll(),this.list.length=0,this.list=0,this._isDestroyed=!0}get isDestroyed(){return this._isDestroyed}},c.OrderedObservable=class extends o{constructor(){super(...arguments),this.sortDirection=s}setAscendingSort(){return this.sortDirection=s,this.sortByOrder()}setDescendingSort(){return this.sortDirection=e,this.sortByOrder()}sortByOrder(){return!this._isDestroyed&&(this.listeners.sort(this.sortDirection),!0)}subscribe(s,e){if(!this.isSubsValid(s))return;const i=new u(this,!1);return this.addObserver(i,s,e),i}pipe(){if(this._isDestroyed)return;const s=new u(this,!0);return this.listeners.push(s),s}unSubscribe(s){this._isDestroyed||(this.isNextProcess&&s?this.listenersForUnsubscribe.push(s):this.listeners&&function(s,e){const i=s.indexOf(e);-1!==i&&s.splice(i,1)}(this.listeners,s))}}})();
1
+ (()=>{"use strict";const s=(s,e)=>s.order>e.order?1:s.order<e.order?-1:0,e=(s,e)=>s.order>e.order?-1:s.order<e.order?1:0;function i(s,e){const i=s.indexOf(e);return-1!==i&&(s[i]=s[s.length-1],s.length=s.length-1,!0)}function t(s){return"next"in s?e=>s.next(e):s}class r{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isNeedUnsubscribe:!1,isAvailable:!1,payload:null}}push(s){return this.chainHandlers.push(s),this}setOnce(){return this.push((s=>{this.listener(s.payload),s.isNeedUnsubscribe=!0}))}unsubscribeByNegative(s){return this.push((e=>{e.isAvailable=!0,s(e.payload)||(e.isNeedUnsubscribe=!0)}))}unsubscribeByPositive(s){return this.push((e=>{e.isAvailable=!0,s(e.payload)&&(e.isNeedUnsubscribe=!0)}))}unsubscribeBy(s){return this.unsubscribeByPositive(s)}emitByNegative(s){return this.push((e=>{s(e.payload)||(e.isAvailable=!0)}))}emitByPositive(s){return this.push((e=>{s(e.payload)&&(e.isAvailable=!0)}))}refine(s){return this.emitByPositive(s)}pushRefiners(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.emitByPositive(s[e]);return this}emitMatch(s){return this.push((e=>{s(e.payload)==e.payload&&(e.isAvailable=!0)}))}switch(){return new n(this)}then(s){return this.push((e=>{e.payload=s(e.payload),e.isAvailable=!0}))}serialize(){return this.push((s=>{s.payload=JSON.stringify(s.payload),s.isAvailable=!0}))}deserialize(){return this.push((s=>{s.payload=JSON.parse(s.payload),s.isAvailable=!0}))}processChain(s){const e=this.chainHandlers,i=this.pipeData;for(let s=0;s<e.length;s++){if(i.isNeedUnsubscribe=!1,i.isAvailable=!1,e[s](i),i.isNeedUnsubscribe)return this.unsubscribe();if(!i.isAvailable)return;if(i.isBreakChain)break}return s(i.payload)}}class n{constructor(s){this.pipe=s,this.caseCounter=s.chainHandlers.length?s.chainHandlers.length:0}subscribe(s,e){return this.pipe.subscribe(s,e)}case(s){this.caseCounter++;const e=this.caseCounter,i=this.pipe.chainHandlers;return i.push((t=>{t.isAvailable=!0,s(t.payload)&&(t.isBreakChain=!0),e!==i.length||t.isBreakChain||(t.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.case(s[e]);return this}}class h extends r{constructor(s,e){super(),this.errorHandler=(s,e)=>{console.log(`(Unit of SubscribeObject).send(${s}) ERROR:`,e)},this._order=0,this.isPaused=!1,this.isPipe=!1,this.observable=s,this.isPipe=!!e}subscribe(s,e){return this.listener=function(s){if(Array.isArray(s)){const e=[];for(let i=0;i<s.length;i++)e.push(t(s[i]));return s=>{for(let i=0;i<e.length;i++)e[i](s)}}return t(s)}(s),e&&(this.errorHandler=e),this}unsubscribe(){this.observable&&(this.observable.unSubscribe(this),this.observable=null,this.listener=null,this.chainHandlers.length=0)}send(s){try{this.pipeData.payload=s,this.pipeData.isBreakChain=!1,this.processValue(s)}catch(e){this.errorHandler(s,e)}}resume(){this.isPaused=!1}pause(){this.isPaused=!0}get order(){return this._order}set order(s){this._order=s}processValue(s){const e=this.listener;return e?this.observable&&!this.isPaused?this.isPipe?this.processChain(e):e(s):void 0:this.unsubscribe()}}class a{constructor(){this.chainHandlers=[],this.pipeData={isBreakChain:!1,isAvailable:!1,payload:null},this.response={isOK:!1,payload:void 0}}get isEmpty(){return!this.chainHandlers.length}push(s){return this.chainHandlers.push(s),this}filter(s){return this.push((e=>{s(e.payload)&&(e.isAvailable=!0)}))}pushFilters(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.filter(s[e]);return this}switch(){return new l(this)}processChain(s){const e=this.chainHandlers,i=this.pipeData,t=this.response;t.isOK=!1,t.payload=void 0,i.payload=s,i.isBreakChain=!1;try{for(let s=0;s<e.length;s++){if(i.isAvailable=!1,e[s](i),!i.isAvailable)return t;if(i.isBreakChain)break}}catch(s){return this.errorHandler?this.errorHandler(s,"Filter.processChain ERROR:"):console.log("Filter.processChain ERROR:",s),t}return t.isOK=!0,t.payload=i.payload,t}addErrorHandler(s){this.errorHandler=s}}class l{constructor(s){this.pipe=s,this.caseCounter=s.chainHandlers.length?s.chainHandlers.length:0}case(s){this.caseCounter++;const e=this.caseCounter,i=this.pipe.chainHandlers;return i.push((t=>{t.isAvailable=!0,s(t.payload)&&(t.isBreakChain=!0),e!==i.length||t.isBreakChain||(t.isAvailable=!1)})),this}pushCases(s){if(!Array.isArray(s))return this;for(let e=0;e<s.length;e++)this.case(s[e]);return this}}class u{constructor(s){this.value=s,this.listeners=[],this._isEnable=!0,this._isDestroyed=!1,this.isNextProcess=!1,this.listenersForUnsubscribe=[],this.filterCase=new a}addFilter(s){return s&&this.filterCase.addErrorHandler(s),this.filterCase}disable(){this._isEnable=!1}enable(){this._isEnable=!0}get isEnable(){return this._isEnable}next(s){if(!this._isDestroyed&&this._isEnable&&(this.filterCase.isEmpty||this.filterCase.processChain(s).isOK)){this.isNextProcess=!0,this.value=s;for(let e=0;e<this.listeners.length;e++)this.listeners[e].send(s);this.isNextProcess=!1,this.listenersForUnsubscribe.length&&this.handleListenersForUnsubscribe()}}stream(s){if(!this._isDestroyed&&this._isEnable)for(let e=0;e<s.length;e++)this.next(s[e])}handleListenersForUnsubscribe(){const s=this.listenersForUnsubscribe.length;for(let e=0;e<s;e++)this.unSubscribe(this.listenersForUnsubscribe[e]);this.listenersForUnsubscribe.length=0}unSubscribe(s){this._isDestroyed||(this.isNextProcess&&s?this.listenersForUnsubscribe.push(s):this.listeners&&i(this.listeners,s))}destroy(){this.value=null,this.unsubscribeAll(),this.listeners=null,this._isDestroyed=!0}unsubscribeAll(){this._isDestroyed||(this.listeners.length=0)}getValue(){if(!this._isDestroyed)return this.value}size(){return this._isDestroyed?0:this.listeners.length}subscribe(s,e){if(!this.isSubsValid(s))return;const i=new h(this,!1);return this.addObserver(i,s,e),i}addObserver(s,e,i){s.subscribe(e,i),this.listeners.push(s)}isSubsValid(s){return!this._isDestroyed&&!!s}pipe(){if(this._isDestroyed)return;const s=new h(this,!0);return this.listeners.push(s),s}get isDestroyed(){return this._isDestroyed}}class o extends h{constructor(s,e){super(s,e)}get order(){return this._order}set order(s){!this.observable||this.observable&&this.observable.isDestroyed?this._order=void 0:(this._order=s,this.observable.sortByOrder())}subscribe(s,e){return super.subscribe(s,e),this}setOnce(){return super.setOnce()}unsubscribeByNegative(s){return super.unsubscribeByNegative(s)}unsubscribeByPositive(s){return super.unsubscribeByPositive(s)}emitByNegative(s){return super.emitByNegative(s)}emitByPositive(s){return super.emitByPositive(s)}emitMatch(s){return super.emitMatch(s)}}const c=window;c.Observable=u,c.Collector=class{constructor(){this.list=[],this._isDestroyed=!1}collect(...s){this._isDestroyed||this.list.push(...s)}unsubscribe(s){this._isDestroyed||(s?.unsubscribe(),i(this.list,s))}unsubscribeAll(){if(!this._isDestroyed)for(;this.list.length>0;)this.unsubscribe(this.list.pop())}size(){return this._isDestroyed?0:this.list.length}destroy(){this.unsubscribeAll(),this.list.length=0,this.list=0,this._isDestroyed=!0}get isDestroyed(){return this._isDestroyed}},c.OrderedObservable=class extends u{constructor(){super(...arguments),this.sortDirection=s}setAscendingSort(){return this.sortDirection=s,this.sortByOrder()}setDescendingSort(){return this.sortDirection=e,this.sortByOrder()}sortByOrder(){return!this._isDestroyed&&(this.listeners.sort(this.sortDirection),!0)}subscribe(s,e){if(!this.isSubsValid(s))return;const i=new o(this,!1);return this.addObserver(i,s,e),i}pipe(){if(this._isDestroyed)return;const s=new o(this,!0);return this.listeners.push(s),s}unSubscribe(s){this._isDestroyed||(this.isNextProcess&&s?this.listenersForUnsubscribe.push(s):this.listeners&&function(s,e){const i=s.indexOf(e);-1!==i&&s.splice(i,1)}(this.listeners,s))}}})();
@@ -1,10 +1,11 @@
1
- import { ICallback, IChainCallback, IErrorCallback, IFilter, IFilterCase, IFilterPayload, IFilterResponse, IFilterSetup, IFilterSwitch } from "./Types";
1
+ import { ICallback, IErrorCallback, IFilter, IFilterCase, IFilterChainCallback, IFilterPayload, IFilterResponse, IFilterSetup, IFilterSwitch } from "./Types";
2
2
  export declare class FilterCollection<T> implements IFilter<T>, IFilterSwitch<T> {
3
- chainHandlers: IChainCallback[];
3
+ chainHandlers: IFilterChainCallback[];
4
4
  pipeData: IFilterPayload;
5
5
  response: IFilterResponse;
6
6
  private errorHandler;
7
7
  get isEmpty(): boolean;
8
+ private push;
8
9
  filter(condition: ICallback<any>): IFilterSetup<T>;
9
10
  pushFilters(conditions: ICallback<any>[]): IFilterSetup<T>;
10
11
  switch(): FilterSwitchCase<T>;
@@ -9,13 +9,15 @@ class FilterCollection {
9
9
  get isEmpty() {
10
10
  return !this.chainHandlers.length;
11
11
  }
12
+ push(callback) {
13
+ this.chainHandlers.push(callback);
14
+ return this;
15
+ }
12
16
  filter(condition) {
13
- const data = this.pipeData;
14
- this.chainHandlers.push(() => {
17
+ return this.push((data) => {
15
18
  if (condition(data.payload))
16
19
  data.isAvailable = true;
17
20
  });
18
- return this;
19
21
  }
20
22
  pushFilters(conditions) {
21
23
  if (!Array.isArray(conditions))
@@ -38,7 +40,7 @@ class FilterCollection {
38
40
  try {
39
41
  for (let i = 0; i < chain.length; i++) {
40
42
  data.isAvailable = false;
41
- chain[i]();
43
+ chain[i](data);
42
44
  if (!data.isAvailable)
43
45
  return response;
44
46
  if (data.isBreakChain)
@@ -73,9 +75,8 @@ class FilterSwitchCase {
73
75
  case(condition) {
74
76
  this.caseCounter++;
75
77
  const id = this.caseCounter;
76
- const data = this.pipe.pipeData;
77
78
  const chain = this.pipe.chainHandlers;
78
- chain.push(() => {
79
+ chain.push((data) => {
79
80
  data.isAvailable = true;
80
81
  if (condition(data.payload))
81
82
  data.isBreakChain = true;
@@ -3,6 +3,7 @@ export declare abstract class Pipe<T> implements ISubscribe<T> {
3
3
  chainHandlers: IChainCallback[];
4
4
  pipeData: IPipePayload;
5
5
  abstract subscribe(listener: IListener<T> | ISetObservableValue, errorHandler?: IErrorCallback): ISubscriptionLike | undefined;
6
+ private push;
6
7
  setOnce(): ISubscribe<T>;
7
8
  unsubscribeByNegative(condition: ICallback<T>): ISetup<T>;
8
9
  unsubscribeByPositive(condition: ICallback<T>): ISetup<T>;
@@ -4,50 +4,44 @@ exports.SwitchCase = exports.Pipe = void 0;
4
4
  class Pipe {
5
5
  chainHandlers = [];
6
6
  pipeData = { isBreakChain: false, isNeedUnsubscribe: false, isAvailable: false, payload: null };
7
+ push(callback) {
8
+ this.chainHandlers.push(callback);
9
+ return this;
10
+ }
7
11
  setOnce() {
8
- const data = this.pipeData;
9
- this.chainHandlers.push(() => {
12
+ return this.push((data) => {
10
13
  this.listener(data.payload);
11
14
  data.isNeedUnsubscribe = true;
12
15
  });
13
- return this;
14
16
  }
15
17
  unsubscribeByNegative(condition) {
16
- const data = this.pipeData;
17
- this.chainHandlers.push(() => {
18
+ return this.push((data) => {
18
19
  data.isAvailable = true;
19
20
  if (!condition(data.payload))
20
21
  data.isNeedUnsubscribe = true;
21
22
  });
22
- return this;
23
23
  }
24
24
  unsubscribeByPositive(condition) {
25
- const data = this.pipeData;
26
- this.chainHandlers.push(() => {
25
+ return this.push((data) => {
27
26
  data.isAvailable = true;
28
27
  if (condition(data.payload))
29
28
  data.isNeedUnsubscribe = true;
30
29
  });
31
- return this;
32
30
  }
33
31
  unsubscribeBy(condition) {
34
32
  return this.unsubscribeByPositive(condition);
35
33
  }
36
34
  emitByNegative(condition) {
37
- const data = this.pipeData;
38
- this.chainHandlers.push(() => {
35
+ return this.push((data) => {
39
36
  if (!condition(data.payload))
40
37
  data.isAvailable = true;
41
38
  });
42
- return this;
43
39
  }
44
40
  emitByPositive(condition) {
45
- const data = this.pipeData;
46
- this.chainHandlers.push(() => {
41
+ return this.push((data) => {
47
42
  if (condition(data.payload))
48
43
  data.isAvailable = true;
49
44
  });
50
- return this;
51
45
  }
52
46
  refine(condition) {
53
47
  return this.emitByPositive(condition);
@@ -60,39 +54,31 @@ class Pipe {
60
54
  return this;
61
55
  }
62
56
  emitMatch(condition) {
63
- const data = this.pipeData;
64
- this.chainHandlers.push(() => {
57
+ return this.push((data) => {
65
58
  if (condition(data.payload) == data.payload)
66
59
  data.isAvailable = true;
67
60
  });
68
- return this;
69
61
  }
70
62
  switch() {
71
63
  return new SwitchCase(this);
72
64
  }
73
65
  then(condition) {
74
- const data = this.pipeData;
75
- this.chainHandlers.push(() => {
66
+ return this.push((data) => {
76
67
  data.payload = condition(data.payload);
77
68
  data.isAvailable = true;
78
69
  });
79
- return this;
80
70
  }
81
71
  serialize() {
82
- const data = this.pipeData;
83
- this.chainHandlers.push(() => {
72
+ return this.push((data) => {
84
73
  data.payload = JSON.stringify(data.payload);
85
74
  data.isAvailable = true;
86
75
  });
87
- return this;
88
76
  }
89
77
  deserialize() {
90
- const data = this.pipeData;
91
- this.chainHandlers.push(() => {
78
+ return this.push((data) => {
92
79
  data.payload = JSON.parse(data.payload);
93
80
  data.isAvailable = true;
94
81
  });
95
- return this;
96
82
  }
97
83
  processChain(listener) {
98
84
  const chain = this.chainHandlers;
@@ -100,7 +86,7 @@ class Pipe {
100
86
  for (let i = 0; i < chain.length; i++) {
101
87
  data.isNeedUnsubscribe = false;
102
88
  data.isAvailable = false;
103
- chain[i]();
89
+ chain[i](data);
104
90
  if (data.isNeedUnsubscribe)
105
91
  return this.unsubscribe();
106
92
  if (!data.isAvailable)
@@ -125,9 +111,8 @@ class SwitchCase {
125
111
  case(condition) {
126
112
  this.caseCounter++;
127
113
  const id = this.caseCounter;
128
- const data = this.pipe.pipeData;
129
114
  const chain = this.pipe.chainHandlers;
130
- chain.push(() => {
115
+ chain.push((data) => {
131
116
  data.isAvailable = true;
132
117
  if (condition(data.payload))
133
118
  data.isBreakChain = true;
@@ -57,7 +57,7 @@ class SubscribeObject extends Pipe_1.Pipe {
57
57
  if (!listener)
58
58
  return this.unsubscribe();
59
59
  if (!this.observable)
60
- return this.unsubscribe();
60
+ return;
61
61
  if (this.isPaused)
62
62
  return;
63
63
  if (!this.isPipe)
@@ -132,7 +132,7 @@ export type IPipePayload = {
132
132
  isAvailable: boolean;
133
133
  payload: any;
134
134
  };
135
- export type IChainCallback = () => void;
135
+ export type IChainCallback = (data: IPipePayload) => void;
136
136
  export type IPipeCase<T> = {
137
137
  case(condition: ICallback<any>): IPipeCase<T> & ISubscribe<T>;
138
138
  pushCases(conditions: ICallback<any>[]): IPipeCase<T> & ISubscribe<T>;
@@ -159,6 +159,7 @@ export type IFilterPayload = {
159
159
  isAvailable: boolean;
160
160
  payload: any;
161
161
  };
162
+ export type IFilterChainCallback = (data: IFilterPayload) => void;
162
163
  export type IFilterResponse = {
163
164
  isOK: boolean;
164
165
  payload: any;