Download code/test/JavaScript/0057782_Sink.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/test/JavaScript/0057782_Sink.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/test/JavaScript/0057782_Sink.js
-
curl -L -o 0057782_Sink.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/test/JavaScript/0057782_Sink.js
1.7 kB
| /** | |
| * Created - 6/1/2017 | |
| * @author Paul Daniels | |
| */ | |
| ; | |
| export class Sink { | |
| constructor(next, error, complete, context) { | |
| this._next || (this._next = next); | |
| this._error || (this._error = error); | |
| this._complete || (this._complete = complete); | |
| this.context = context || this; | |
| this.isStopped = false; | |
| this.sub = null; | |
| } | |
| run(source) { | |
| return this.sub || (this.sub = source.subscribe(this)); | |
| } | |
| next(v) { | |
| if (!this.isStopped) { | |
| this._next.call(this.context, v); | |
| } | |
| } | |
| complete() { | |
| if (!this.isStopped) { | |
| this._complete.call(this.context); | |
| this.unsubscribe(); | |
| } | |
| } | |
| error(e) { | |
| if (!this.isStopped) { | |
| this._error.call(this.context, e); | |
| this.unsubscribe(); | |
| } | |
| } | |
| unsubscribe() { | |
| if (!this.isStopped) { | |
| this._unsubscribe(); | |
| this.sub && this.sub.unsubscribe(); | |
| this.isStopped = true; | |
| } | |
| } | |
| _unsubscribe() {} | |
| } | |
| ; | |
| export class ProtectedSink { | |
| constructor(underlying) { | |
| this.underlying = underlying; | |
| this.isStopped = false; | |
| this.sub = null; | |
| } | |
| run(source) { | |
| return this.sub || (this.sub = source.subscribe(this)); | |
| } | |
| next(v) { | |
| if (!this.isStopped) { | |
| this.underlying.next(v, this); | |
| } | |
| } | |
| complete() { | |
| if (!this.isStopped) { | |
| this.underlying.complete(this); | |
| this.unsubscribe(); | |
| } | |
| } | |
| error(e) { | |
| if (!this.isStopped) { | |
| this.underlying.error(e, this); | |
| this.unsubscribe(); | |
| } | |
| } | |
| unsubscribe() { | |
| if (!this.isStopped) { | |
| this.underlying.unsubscribe && this.underlying.unsubscribe(); | |
| this.sub && this.sub.unsubscribe(); | |
| this.isStopped = true; | |
| } | |
| } | |
| } |