mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2025-09-15 12:27:30 +00:00
24 lines
770 B
JavaScript
24 lines
770 B
JavaScript
import { EmptyError } from './util/EmptyError';
|
|
import { SafeSubscriber } from './Subscriber';
|
|
export function firstValueFrom(source, config) {
|
|
const hasConfig = typeof config === 'object';
|
|
return new Promise((resolve, reject) => {
|
|
const subscriber = new SafeSubscriber({
|
|
next: (value) => {
|
|
resolve(value);
|
|
subscriber.unsubscribe();
|
|
},
|
|
error: reject,
|
|
complete: () => {
|
|
if (hasConfig) {
|
|
resolve(config.defaultValue);
|
|
}
|
|
else {
|
|
reject(new EmptyError());
|
|
}
|
|
},
|
|
});
|
|
source.subscribe(subscriber);
|
|
});
|
|
}
|
|
//# sourceMappingURL=firstValueFrom.js.map
|