UNPKG

ix

Version:

The Interactive Extensions for JavaScript

40 lines (38 loc) 1.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isEmpty = void 0; const tslib_1 = require("tslib"); const withabort_js_1 = require("./operators/withabort.js"); const aborterror_js_1 = require("../aborterror.js"); /** * Determines whether the given async-iterable is empty. * * @template T The type of elements in the source sequence. * @param {AsyncIterable<T>} source The source async-iterable to determine whether it is empty. * @param {AbortSignal} [signal] An optional abort signal to cancel the operation. * @returns {Promise<boolean>} Returns a promise containing true if the sequence is empty, otherwise false. */ function isEmpty(source, signal) { var _a, e_1, _b, _c; return tslib_1.__awaiter(this, void 0, void 0, function* () { (0, aborterror_js_1.throwIfAborted)(signal); try { for (var _d = true, _e = tslib_1.__asyncValues((0, withabort_js_1.wrapWithAbort)(source, signal)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { _c = _f.value; _d = false; const _ = _c; return false; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); } finally { if (e_1) throw e_1.error; } } return true; }); } exports.isEmpty = isEmpty; //# sourceMappingURL=isempty.js.map