@esmj/observable
Advanced tools
+11
-3
@@ -11,3 +11,3 @@ interface IObserverFunction { | ||
| interface IExtendable { | ||
| pipe<T extends this>(...operations: ((operation: T) => T)[]): T; | ||
| pipe<T extends this>(...operations: ((operation: any) => any)[]): T; | ||
| } | ||
@@ -30,3 +30,3 @@ type IObserver = IObserverObject | IObserverFunction; | ||
| #private; | ||
| pipe<Input extends this, Output extends IObservable>(...operations: any[]): Input | Output; | ||
| pipe(...operations: any[]): any; | ||
| next(...rest: any[]): void; | ||
@@ -40,4 +40,12 @@ error(...rest: any[]): void; | ||
| } | ||
| declare function pipe<Input extends IObservable | unknown, Output = unknown>(...operations: ((operation: Input) => Input)[]): (any: Input) => Input | Output; | ||
| declare function pipe<A, B>(op1: (input: A) => B): (input: A) => B; | ||
| declare function pipe<A, B, C>(op1: (input: A) => B, op2: (input: B) => C): (input: A) => C; | ||
| declare function pipe<A, B, C, D>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D): (input: A) => D; | ||
| declare function pipe<A, B, C, D, E>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E): (input: A) => E; | ||
| declare function pipe<A, B, C, D, E, F>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F): (input: A) => F; | ||
| declare function pipe<A, B, C, D, E, F, G>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G): (input: A) => G; | ||
| declare function pipe<A, B, C, D, E, F, G, H>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H): (input: A) => H; | ||
| declare function pipe<A, B, C, D, E, F, G, H, I>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H, op8: (input: H) => I): (input: A) => I; | ||
| declare function pipe<A, B, C, D, E, F, G, H, I, J>(op1: (input: A) => B, op2: (input: B) => C, op3: (input: C) => D, op4: (input: D) => E, op5: (input: E) => F, op6: (input: F) => G, op7: (input: G) => H, op8: (input: H) => I, op9: (input: I) => J): (input: A) => J; | ||
| export { IExtendable, IObservable, IObserver, IObserverFunction, IObserverObject, Observable, Observer, Subscription, pipe }; |
+3
-6
@@ -41,3 +41,3 @@ var __defProp = Object.defineProperty; | ||
| pipe(...operations) { | ||
| return pipe(...operations)(this); | ||
| return operations.reduce((result, operation) => operation(result), this); | ||
| } | ||
@@ -74,7 +74,4 @@ next(...rest) { | ||
| function pipe(...operations) { | ||
| return (any) => { | ||
| return Array.from(operations).reduce( | ||
| (any2, operation) => operation(any2), | ||
| any | ||
| ); | ||
| return (input) => { | ||
| return operations.reduce((result, operation) => operation(result), input); | ||
| }; | ||
@@ -81,0 +78,0 @@ } |
+3
-6
@@ -16,3 +16,3 @@ // src/index.ts | ||
| pipe(...operations) { | ||
| return pipe(...operations)(this); | ||
| return operations.reduce((result, operation) => operation(result), this); | ||
| } | ||
@@ -49,7 +49,4 @@ next(...rest) { | ||
| function pipe(...operations) { | ||
| return (any) => { | ||
| return Array.from(operations).reduce( | ||
| (any2, operation) => operation(any2), | ||
| any | ||
| ); | ||
| return (input) => { | ||
| return operations.reduce((result, operation) => operation(result), input); | ||
| }; | ||
@@ -56,0 +53,0 @@ } |
+1
-1
| { | ||
| "name": "@esmj/observable", | ||
| "version": "0.3.0", | ||
| "version": "0.4.0", | ||
| "description": "Tiny observable library for other extensibility", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
12910
11.53%184
1.1%