@azure/core-paging 1.2.0 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ## 1.2.1 (2022-01-06)
4
+
5
+ ### Bugs Fixed
6
+
7
+ - Use a TS v3.4-friendly iterator protocol [PR# 19507](https://github.com/Azure/azure-sdk-for-js/pull/19507). Fixed [Issue 19394](https://github.com/Azure/azure-sdk-for-js/issues/19394)
8
+
3
9
  ## 1.2.0 (2021-08-30)
4
10
 
5
11
  ### Features Added
package/dist/index.js CHANGED
@@ -25,7 +25,7 @@ function getPagedAsyncIterator(pagedResult) {
25
25
  },
26
26
  byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
27
27
  return getPageAsyncIterator(pagedResult, settings === null || settings === void 0 ? void 0 : settings.maxPageSize);
28
- })
28
+ }),
29
29
  };
30
30
  }
31
31
  function getItemAsyncIterator(pagedResult, maxPageSize) {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/getPagedAsyncIterator.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PagedAsyncIterableIterator, PageSettings, PagedResult } from \"./models\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nexport function getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n ((settings?: PageSettings) => {\n return getPageAsyncIterator(\n pagedResult as PagedResult<TPage, PageSettings, TLink>,\n settings?.maxPageSize\n );\n })\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult, maxPageSize);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* (pages as unknown) as AsyncIterableIterator<TElement>;\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* (page as unknown) as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TPage> {\n let response = await pagedResult.getPage(pagedResult.firstPageLink, maxPageSize);\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink, maxPageSize);\n yield response.page;\n }\n}\n"],"names":["__asyncDelegator","__asyncValues"],"mappings":";;;;;;;AAAA;AAKA;;;;;;;SAOgB,qBAAqB,CAMnC,WAAqD;;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;SACpB;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,EACJ,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,oCAClB,CAAC,QAAuB;YACvB,OAAO,oBAAoB,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":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PageSettings, PagedAsyncIterableIterator, PagedResult } from \"./models\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nexport function getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n ((settings?: PageSettings) => {\n return getPageAsyncIterator(\n pagedResult as PagedResult<TPage, PageSettings, TLink>,\n settings?.maxPageSize\n );\n }),\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult, maxPageSize);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* pages as unknown as AsyncIterableIterator<TElement>;\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* page as unknown as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TPage> {\n let response = await pagedResult.getPage(pagedResult.firstPageLink, maxPageSize);\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink, maxPageSize);\n yield response.page;\n }\n}\n"],"names":["__asyncDelegator","__asyncValues"],"mappings":";;;;;;;AAAA;AAKA;;;;;;;SAOgB,qBAAqB,CAMnC,WAAqD;;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;SACpB;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,EACJ,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,oCAClB,CAAC,QAAuB;YACvB,OAAO,oBAAoB,CACzB,WAAsD,EACtD,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CACtB,CAAC;SACH,CAAC;KACL,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAClC,WAAqD,EACrD,WAAoB;;;QAEpB,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,oBAAM,KAAK,CAAC,IAAI,EAAE,CAAA,CAAC;;QAEpC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAClC,0BAAM,QAAQ,CAAC,KAAK,CAAA,CAAC;;YAErB,oBAAA,OAAOA,uBAAAC,oBAAA,KAAmD,CAAA,CAAA,CAAA,CAAC;SAC5D;aAAM;YACL,oBAAA,OAAOD,uBAAAC,oBAAA,QAAQ,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;;gBACtB,KAAyB,IAAA,UAAAA,oBAAA,KAAK,CAAA,WAAA;oBAAnB,MAAM,IAAI,kBAAA,CAAA;;;oBAGnB,oBAAA,OAAOD,uBAAAC,oBAAA,IAA6B,CAAA,CAAA,CAAA,CAAC;iBACtC;;;;;;;;;SACF;KACF;CAAA;AAED,SAAgB,oBAAoB,CAClC,WAAqD,EACrD,WAAoB;;QAEpB,IAAI,QAAQ,GAAG,oBAAM,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA,CAAC;QACjF,0BAAM,QAAQ,CAAC,IAAI,CAAA,CAAC;QACpB,OAAO,QAAQ,CAAC,YAAY,EAAE;YAC5B,QAAQ,GAAG,oBAAM,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA,CAAC;YACzE,0BAAM,QAAQ,CAAC,IAAI,CAAA,CAAC;SACrB;KACF;;;;;"}
@@ -20,7 +20,7 @@ export function getPagedAsyncIterator(pagedResult) {
20
20
  },
21
21
  byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
22
22
  return getPageAsyncIterator(pagedResult, settings === null || settings === void 0 ? void 0 : settings.maxPageSize);
23
- })
23
+ }),
24
24
  };
25
25
  }
26
26
  function getItemAsyncIterator(pagedResult, maxPageSize) {
@@ -1 +1 @@
1
- {"version":3,"file":"getPagedAsyncIterator.js","sourceRoot":"","sources":["../../src/getPagedAsyncIterator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAIlC;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAMnC,WAAqD;;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EACJ,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,mCACnB,CAAC,CAAC,QAAuB,EAAE,EAAE;YAC3B,OAAO,oBAAoB,CACzB,WAAsD,EACtD,QAAQ,aAAR,QAAQ,uBAA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(c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PagedAsyncIterableIterator, PageSettings, PagedResult } from \"./models\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nexport function getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n ((settings?: PageSettings) => {\n return getPageAsyncIterator(\n pagedResult as PagedResult<TPage, PageSettings, TLink>,\n settings?.maxPageSize\n );\n })\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult, maxPageSize);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* (pages as unknown) as AsyncIterableIterator<TElement>;\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* (page as unknown) as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TPage> {\n let response = await pagedResult.getPage(pagedResult.firstPageLink, maxPageSize);\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink, maxPageSize);\n yield response.page;\n }\n}\n"]}
1
+ {"version":3,"file":"getPagedAsyncIterator.js","sourceRoot":"","sources":["../../src/getPagedAsyncIterator.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAIlC;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAMnC,WAAqD;;IAErD,MAAM,IAAI,GAAG,oBAAoB,CAAwC,WAAW,CAAC,CAAC;IACtF,OAAO;QACL,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QACD,CAAC,MAAM,CAAC,aAAa,CAAC;YACpB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EACJ,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,MAAM,mCACnB,CAAC,CAAC,QAAuB,EAAE,EAAE;YAC3B,OAAO,oBAAoB,CACzB,WAAsD,EACtD,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CACtB,CAAC;QACJ,CAAC,CAAC;KACL,CAAC;AACJ,CAAC;AAED,SAAgB,oBAAoB,CAClC,WAAqD,EACrD,WAAoB;;;QAEpB,MAAM,KAAK,GAAG,oBAAoB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC7D,MAAM,QAAQ,GAAG,cAAM,KAAK,CAAC,IAAI,EAAE,CAAA,CAAC;QACpC,6FAA6F;QAC7F,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;YAClC,oBAAM,QAAQ,CAAC,KAAK,CAAA,CAAC;YACrB,sFAAsF;YACtF,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,KAAmD,CAAA,CAAA,CAAA,CAAC;SAC5D;aAAM;YACL,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,QAAQ,CAAC,KAAK,CAAA,CAAA,CAAA,CAAC;;gBACtB,KAAyB,IAAA,UAAA,cAAA,KAAK,CAAA,WAAA;oBAAnB,MAAM,IAAI,kBAAA,CAAA;oBACnB,gGAAgG;oBAChG,gDAAgD;oBAChD,cAAA,KAAK,CAAC,CAAC,iBAAA,cAAA,IAA6B,CAAA,CAAA,CAAA,CAAC;iBACtC;;;;;;;;;SACF;IACH,CAAC;CAAA;AAED,SAAgB,oBAAoB,CAClC,WAAqD,EACrD,WAAoB;;QAEpB,IAAI,QAAQ,GAAG,cAAM,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,CAAA,CAAC;QACjF,oBAAM,QAAQ,CAAC,IAAI,CAAA,CAAC;QACpB,OAAO,QAAQ,CAAC,YAAY,EAAE;YAC5B,QAAQ,GAAG,cAAM,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,WAAW,CAAC,CAAA,CAAC;YACzE,oBAAM,QAAQ,CAAC,IAAI,CAAA,CAAC;SACrB;IACH,CAAC;CAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { PageSettings, PagedAsyncIterableIterator, PagedResult } from \"./models\";\n\n/**\n * returns an async iterator that iterates over results. It also has a `byPage`\n * method that returns pages of items at once.\n *\n * @param pagedResult - an object that specifies how to get pages.\n * @returns a paged async iterator that iterates over results.\n */\nexport function getPagedAsyncIterator<\n TElement,\n TPage = TElement[],\n TPageSettings = PageSettings,\n TLink = string\n>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>\n): PagedAsyncIterableIterator<TElement, TPage, TPageSettings> {\n const iter = getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(pagedResult);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage:\n pagedResult?.byPage ??\n ((settings?: PageSettings) => {\n return getPageAsyncIterator(\n pagedResult as PagedResult<TPage, PageSettings, TLink>,\n settings?.maxPageSize\n );\n }),\n };\n}\n\nasync function* getItemAsyncIterator<TElement, TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TElement> {\n const pages = getPageAsyncIterator(pagedResult, maxPageSize);\n const firstVal = await pages.next();\n // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is\n if (!Array.isArray(firstVal.value)) {\n yield firstVal.value;\n // `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case\n yield* pages as unknown as AsyncIterableIterator<TElement>;\n } else {\n yield* firstVal.value;\n for await (const page of pages) {\n // pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,\n // it must be the case that `TPage = TElement[]`\n yield* page as unknown as TElement[];\n }\n }\n}\n\nasync function* getPageAsyncIterator<TPage, TLink, TPageSettings>(\n pagedResult: PagedResult<TPage, TPageSettings, TLink>,\n maxPageSize?: number\n): AsyncIterableIterator<TPage> {\n let response = await pagedResult.getPage(pagedResult.firstPageLink, maxPageSize);\n yield response.page;\n while (response.nextPageLink) {\n response = await pagedResult.getPage(response.nextPageLink, maxPageSize);\n yield response.page;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * An interface that tracks the settings for paged iteration\n */\nexport interface PageSettings {\n /**\n * The token that keeps track of where to continue the iterator\n */\n continuationToken?: string;\n /**\n * The size of the page during paged iteration\n */\n maxPageSize?: number;\n}\n/**\n * An interface that allows async iterable iteration both to completion and by page.\n */\nexport interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {\n /**\n * The next method, part of the iteration protocol\n */\n next(): Promise<IteratorResult<T, T>>;\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;\n}\n\n/**\n * An interface that describes how to communicate with the service.\n */\nexport interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {\n /**\n * Link to the first page of results.\n */\n firstPageLink: TLink;\n /**\n * A method that returns a page of results.\n */\n getPage: (\n pageLink: TLink,\n maxPageSize?: number\n ) => Promise<{ page: TPage; nextPageLink?: TLink }>;\n /**\n * a function to implement the `byPage` method on the paged async iterator. The default is\n * one that sets the `maxPageSizeParam` from `settings.maxPageSize`.\n */\n byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n}\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * An interface that tracks the settings for paged iteration\n */\nexport interface PageSettings {\n /**\n * The token that keeps track of where to continue the iterator\n */\n continuationToken?: string;\n /**\n * The size of the page during paged iteration\n */\n maxPageSize?: number;\n}\n/**\n * An interface that allows async iterable iteration both to completion and by page.\n */\nexport interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {\n /**\n * The next method, part of the iteration protocol\n */\n next(): Promise<IteratorResult<T>>;\n /**\n * The connection to the async iterator, part of the iteration protocol\n */\n [Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;\n /**\n * Return an AsyncIterableIterator that works a page at a time\n */\n byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;\n}\n\n/**\n * An interface that describes how to communicate with the service.\n */\nexport interface PagedResult<TPage, TPageSettings = PageSettings, TLink = string> {\n /**\n * Link to the first page of results.\n */\n firstPageLink: TLink;\n /**\n * A method that returns a page of results.\n */\n getPage: (\n pageLink: TLink,\n maxPageSize?: number\n ) => Promise<{ page: TPage; nextPageLink?: TLink }>;\n /**\n * a function to implement the `byPage` method on the paged async iterator. The default is\n * one that sets the `maxPageSizeParam` from `settings.maxPageSize`.\n */\n byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure/core-paging",
3
3
  "author": "Microsoft Corporation",
4
4
  "sdk-type": "client",
5
- "version": "1.2.0",
5
+ "version": "1.2.1",
6
6
  "description": "Core types for paging async iterable iterators",
7
7
  "tags": [
8
8
  "microsoft",
@@ -49,7 +49,6 @@
49
49
  "build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local && npm run build:types",
50
50
  "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
51
51
  "clean": "rimraf dist dist-* temp *.tgz types *.log",
52
- "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src",
53
52
  "execute:samples": "echo skipped",
54
53
  "extract-api": "tsc -p . && api-extractor run --local",
55
54
  "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
@@ -74,7 +73,7 @@
74
73
  },
75
74
  "devDependencies": {
76
75
  "@azure/dev-tool": "^1.0.0",
77
- "@microsoft/api-extractor": "7.7.11",
76
+ "@microsoft/api-extractor": "^7.18.11",
78
77
  "@azure/eslint-plugin-azure-sdk": "^3.0.0",
79
78
  "@types/chai": "^4.1.6",
80
79
  "@types/mocha": "^7.0.2",
@@ -94,11 +93,18 @@
94
93
  "karma-mocha-reporter": "^2.2.5",
95
94
  "karma-sourcemap-loader": "^0.3.8",
96
95
  "mocha": "^7.1.1",
97
- "mocha-junit-reporter": "^1.18.0",
98
- "prettier": "^1.16.4",
96
+ "mocha-junit-reporter": "^2.0.0",
97
+ "prettier": "^2.5.1",
99
98
  "rimraf": "^3.0.0",
100
99
  "rollup": "^1.16.3",
101
- "typescript": "~4.2.0",
102
- "typedoc": "0.15.2"
100
+ "typescript": "~4.2.0"
101
+ },
102
+ "//sampleConfiguration": {
103
+ "skipFolder": true,
104
+ "disableDocsMs": true,
105
+ "productName": "Azure SDK Core",
106
+ "productSlugs": [
107
+ "azure"
108
+ ]
103
109
  }
104
110
  }
@@ -13,7 +13,7 @@ export declare interface PagedAsyncIterableIterator<T, PageT = T[], PageSettings
13
13
  /**
14
14
  * The next method, part of the iteration protocol
15
15
  */
16
- next(): Promise<IteratorResult<T, T>>;
16
+ next(): Promise<IteratorResult<T>>;
17
17
  /**
18
18
  * The connection to the async iterator, part of the iteration protocol
19
19
  */
@@ -0,0 +1,2 @@
1
+ export declare function main(): Promise<void>;
2
+ //# sourceMappingURL=getPagedAsyncIteratorSample.d.ts.map
@@ -1,4 +1,4 @@
1
- import { PagedAsyncIterableIterator, PageSettings, PagedResult } from "./models";
1
+ import { PageSettings, PagedAsyncIterableIterator, PagedResult } from "./models";
2
2
  /**
3
3
  * returns an async iterator that iterates over results. It also has a `byPage`
4
4
  * method that returns pages of items at once.
@@ -18,7 +18,7 @@ export interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = Page
18
18
  /**
19
19
  * The next method, part of the iteration protocol
20
20
  */
21
- next(): Promise<IteratorResult<T, T>>;
21
+ next(): Promise<IteratorResult<T>>;
22
22
  /**
23
23
  * The connection to the async iterator, part of the iteration protocol
24
24
  */
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * returns an async iterator that iterates over results. It also has a `byPage`
4
3
  * method that returns pages of items at once.
@@ -15,7 +14,7 @@ export declare interface PagedAsyncIterableIterator<T, PageT = T[], PageSettings
15
14
  /**
16
15
  * The next method, part of the iteration protocol
17
16
  */
18
- next(): Promise<IteratorResult<T, T>>;
17
+ next(): Promise<IteratorResult<T>>;
19
18
  /**
20
19
  * The connection to the async iterator, part of the iteration protocol
21
20
  */