@graphql-tools/utils 8.5.4 → 8.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -4183,14 +4183,12 @@ function withCancel(asyncIterable, onCancel) {
4183
4183
  get(asyncIterable, prop) {
4184
4184
  if (Symbol.asyncIterator === prop) {
4185
4185
  return function getAsyncIteratorWithCancel() {
4186
+ var _a;
4186
4187
  const asyncIterator = asyncIterable[Symbol.asyncIterator]();
4187
- if (!asyncIterator.return) {
4188
- asyncIterator.return = defaultReturn;
4189
- }
4190
- const savedReturn = asyncIterator.return.bind(asyncIterator);
4188
+ const existingReturn = ((_a = asyncIterator.return) === null || _a === void 0 ? void 0 : _a.bind(asyncIterator)) || defaultReturn;
4191
4189
  asyncIterator.return = async function extendedReturn(value) {
4192
4190
  const returnValue = await onCancel(value);
4193
- return savedReturn(returnValue);
4191
+ return existingReturn(returnValue);
4194
4192
  };
4195
4193
  return asyncIterator;
4196
4194
  };
package/index.mjs CHANGED
@@ -4181,14 +4181,12 @@ function withCancel(asyncIterable, onCancel) {
4181
4181
  get(asyncIterable, prop) {
4182
4182
  if (Symbol.asyncIterator === prop) {
4183
4183
  return function getAsyncIteratorWithCancel() {
4184
+ var _a;
4184
4185
  const asyncIterator = asyncIterable[Symbol.asyncIterator]();
4185
- if (!asyncIterator.return) {
4186
- asyncIterator.return = defaultReturn;
4187
- }
4188
- const savedReturn = asyncIterator.return.bind(asyncIterator);
4186
+ const existingReturn = ((_a = asyncIterator.return) === null || _a === void 0 ? void 0 : _a.bind(asyncIterator)) || defaultReturn;
4189
4187
  asyncIterator.return = async function extendedReturn(value) {
4190
4188
  const returnValue = await onCancel(value);
4191
- return savedReturn(returnValue);
4189
+ return existingReturn(returnValue);
4192
4190
  };
4193
4191
  return asyncIterator;
4194
4192
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "8.5.4",
3
+ "version": "8.5.5",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
package/withCancel.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function withCancel<T>(asyncIterable: AsyncIterable<T>, onCancel: (value?: any) => void | Promise<void>): AsyncIterable<T | undefined>;
1
+ export declare function withCancel<T, TAsyncIterable extends AsyncIterable<T>>(asyncIterable: TAsyncIterable, onCancel: (value?: any) => void | Promise<void>): TAsyncIterable;