* Takes a `component` function and an optional `scope` string, and returns a * scoped version of the `component` function. * * When the scoped component is invoked, each source provided to the scoped * component is isolated to the given `scope` using * `source.isolateSource(source, scope)`, if
(component: Component<SmallSo, SmallSi>,
scope: any = newScope())
| 103 | * @function isolate |
| 104 | */ |
| 105 | function isolate<SmallSo, SmallSi>(component: Component<SmallSo, SmallSi>, |
| 106 | scope: any = newScope()): Component<BigSo, BigSi> { |
| 107 | checkIsolateArgs(component, scope); |
| 108 | const convertedScope: string = typeof scope === 'string' ? scope : scope.toString(); |
| 109 | return function scopedComponent(sources: BigSo, ...rest: Array<any>): BigSi { |
| 110 | const scopedSources = isolateAllSources(sources, convertedScope); |
| 111 | const sinks = component(scopedSources, ...rest); |
| 112 | const scopedSinks = isolateAllSinks(sources, sinks, convertedScope); |
| 113 | return scopedSinks; |
| 114 | }; |
| 115 | } |
| 116 | |
| 117 | (isolate as any).reset = () => counter = 0; |
| 118 |
no test coverage detected