callbag-toolkit
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -38,2 +38,3 @@ "use strict"; | ||
const markDisposed = () => state !== 'disposed' && (state = 'disposed'); | ||
let init = false; | ||
/** talkback - sends messages back upstream */ | ||
@@ -44,7 +45,12 @@ // eslint-disable-next-line @typescript-eslint/no-shadow | ||
return; | ||
// got a request from the sink for the next value, let's process it | ||
if (askToPull && args[0] === types_1.DATA) | ||
askToPull(); | ||
else if (dispose && args[0] === types_1.END) | ||
markDisposed() && dispose(); | ||
if (init) { | ||
// got a request from the sink for the next value, let's process it | ||
if (askToPull && args[0] === types_1.DATA) | ||
askToPull(); | ||
else if (dispose && args[0] === types_1.END) | ||
markDisposed() && dispose(); | ||
} | ||
else { | ||
init = args; | ||
} | ||
}; | ||
@@ -61,4 +67,7 @@ /** sink */ | ||
const askToPull = typeof consumer === 'object' ? consumer === null || consumer === void 0 ? void 0 : consumer.pull : undefined; | ||
if (init) | ||
upstream(...init); | ||
init = true; | ||
}; | ||
exports.createSource = createSource; | ||
//# sourceMappingURL=create.js.map |
@@ -1,2 +0,2 @@ | ||
export type { Callbag, Sink, Source, SourceFactory, SourceOperator, UnwrapSink, UnwrapSource, } from 'callbag'; | ||
export type { Callbag, CallbagArgs, Sink, Source, SourceFactory, SourceOperator, UnwrapSink, UnwrapSource, } from 'callbag'; | ||
export declare const START = 0; | ||
@@ -3,0 +3,0 @@ export declare const DATA = 1; |
@@ -34,2 +34,3 @@ /* eslint-disable @typescript-eslint/no-use-before-define,@typescript-eslint/no-unused-expressions,no-return-assign */ | ||
const markDisposed = () => state !== 'disposed' && (state = 'disposed'); | ||
let init = false; | ||
/** talkback - sends messages back upstream */ | ||
@@ -40,7 +41,12 @@ // eslint-disable-next-line @typescript-eslint/no-shadow | ||
return; | ||
// got a request from the sink for the next value, let's process it | ||
if (askToPull && args[0] === DATA) | ||
askToPull(); | ||
else if (dispose && args[0] === END) | ||
markDisposed() && dispose(); | ||
if (init) { | ||
// got a request from the sink for the next value, let's process it | ||
if (askToPull && args[0] === DATA) | ||
askToPull(); | ||
else if (dispose && args[0] === END) | ||
markDisposed() && dispose(); | ||
} | ||
else { | ||
init = args; | ||
} | ||
}; | ||
@@ -57,3 +63,6 @@ /** sink */ | ||
const askToPull = typeof consumer === 'object' ? consumer === null || consumer === void 0 ? void 0 : consumer.pull : undefined; | ||
if (init) | ||
upstream(...init); | ||
init = true; | ||
}; | ||
//# sourceMappingURL=create.js.map |
@@ -1,2 +0,2 @@ | ||
export type { Callbag, Sink, Source, SourceFactory, SourceOperator, UnwrapSink, UnwrapSource, } from 'callbag'; | ||
export type { Callbag, CallbagArgs, Sink, Source, SourceFactory, SourceOperator, UnwrapSink, UnwrapSource, } from 'callbag'; | ||
export declare const START = 0; | ||
@@ -3,0 +3,0 @@ export declare const DATA = 1; |
@@ -56,3 +56,3 @@ { | ||
}, | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
} |
/* eslint-disable @typescript-eslint/no-use-before-define,@typescript-eslint/no-unused-expressions,no-return-assign */ | ||
import type { | ||
CallbagArgs, | ||
ConsumerHandlers, | ||
@@ -48,2 +49,3 @@ Sink, | ||
const markDisposed = () => state !== 'disposed' && (state = 'disposed') | ||
let init: CallbagArgs<never, Out> | boolean = false | ||
@@ -54,5 +56,9 @@ /** talkback - sends messages back upstream */ | ||
if (state === 'disposed') return | ||
// got a request from the sink for the next value, let's process it | ||
if (askToPull && args[0] === DATA) askToPull() | ||
else if (dispose && args[0] === END) markDisposed() && dispose() | ||
if (init) { | ||
// got a request from the sink for the next value, let's process it | ||
if (askToPull && args[0] === DATA) askToPull() | ||
else if (dispose && args[0] === END) markDisposed() && dispose() | ||
} else { | ||
init = args | ||
} | ||
} | ||
@@ -72,2 +78,4 @@ | ||
const askToPull = typeof consumer === 'object' ? consumer?.pull : undefined | ||
if (init) upstream(...init) | ||
init = true | ||
} |
export type { | ||
Callbag, | ||
CallbagArgs, | ||
Sink, | ||
@@ -4,0 +5,0 @@ Source, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105232
1241