diff options
author | Minteck <contact@minteck.org> | 2023-01-10 14:54:04 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-01-10 14:54:04 +0100 |
commit | 99c1d9af689e5325f3cf535c4007b3aeb8325229 (patch) | |
tree | e663b3c2ebdbd67c818ac0c5147f0ce1d2463cda /alarm/node_modules/graphql/subscription/mapAsyncIterator.mjs | |
parent | 9871b03912fc28ad38b4037ebf26a78aa937baba (diff) | |
download | pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.gz pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.tar.bz2 pluralconnect-99c1d9af689e5325f3cf535c4007b3aeb8325229.zip |
Update - This is an automated commit
Diffstat (limited to 'alarm/node_modules/graphql/subscription/mapAsyncIterator.mjs')
-rw-r--r-- | alarm/node_modules/graphql/subscription/mapAsyncIterator.mjs | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/alarm/node_modules/graphql/subscription/mapAsyncIterator.mjs b/alarm/node_modules/graphql/subscription/mapAsyncIterator.mjs deleted file mode 100644 index ffe23e0..0000000 --- a/alarm/node_modules/graphql/subscription/mapAsyncIterator.mjs +++ /dev/null @@ -1,79 +0,0 @@ -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - -import { SYMBOL_ASYNC_ITERATOR } from "../polyfills/symbols.mjs"; - -/** - * Given an AsyncIterable and a callback function, return an AsyncIterator - * which produces values mapped via calling the callback function. - */ -export default function mapAsyncIterator(iterable, callback, rejectCallback) { - // $FlowFixMe[prop-missing] - var iteratorMethod = iterable[SYMBOL_ASYNC_ITERATOR]; - var iterator = iteratorMethod.call(iterable); - var $return; - var abruptClose; - - if (typeof iterator.return === 'function') { - $return = iterator.return; - - abruptClose = function abruptClose(error) { - var rethrow = function rethrow() { - return Promise.reject(error); - }; - - return $return.call(iterator).then(rethrow, rethrow); - }; - } - - function mapResult(result) { - return result.done ? result : asyncMapValue(result.value, callback).then(iteratorResult, abruptClose); - } - - var mapReject; - - if (rejectCallback) { - // Capture rejectCallback to ensure it cannot be null. - var reject = rejectCallback; - - mapReject = function mapReject(error) { - return asyncMapValue(error, reject).then(iteratorResult, abruptClose); - }; - } - /* TODO: Flow doesn't support symbols as keys: - https://github.com/facebook/flow/issues/3258 */ - - - return _defineProperty({ - next: function next() { - return iterator.next().then(mapResult, mapReject); - }, - return: function _return() { - return $return ? $return.call(iterator).then(mapResult, mapReject) : Promise.resolve({ - value: undefined, - done: true - }); - }, - throw: function _throw(error) { - if (typeof iterator.throw === 'function') { - return iterator.throw(error).then(mapResult, mapReject); - } - - return Promise.reject(error).catch(abruptClose); - } - }, SYMBOL_ASYNC_ITERATOR, function () { - return this; - }); -} - -function asyncMapValue(value, callback) { - return new Promise(function (resolve) { - return resolve(callback(value)); - }); -} - -function iteratorResult(value) { - return { - value: value, - done: false - }; -} |