Socket
Socket
Sign inDemoInstall

@azure/core-paging

Package Overview
Dependencies
Maintainers
1
Versions
251
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azure/core-paging - npm Package Compare versions

Comparing version 1.1.4-alpha.20210729.2 to 1.2.0-alpha.20210811.3

types/3.1/src/getPagedAsyncIterator.d.ts

5

CHANGELOG.md
# Release History
## 1.1.4 (Unreleased)
## 1.2.0 (Unreleased)
### Features Added
- Add `getPagedAsyncIterator` that does the heavy lifting to build a paged async iterator.
## 1.1.3 (2020-09-30)

@@ -7,0 +10,0 @@

3

dist-esm/src/index.js
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
import "@azure/core-asynciterator-polyfill";
export * from "./models";
export * from "./getPagedAsyncIterator";
//# sourceMappingURL=index.js.map

@@ -1,5 +0,74 @@

"use strict";
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
require('@azure/core-asynciterator-polyfill');
var tslib = require('tslib');
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
require("@azure/core-asynciterator-polyfill");
/**
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
function getPagedAsyncIterator(pagedResult) {
var _a;
const iter = getItemAsyncIterator(pagedResult);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: (_a = pagedResult === null || pagedResult === void 0 ? void 0 : pagedResult.byPage) !== null && _a !== void 0 ? _a : ((settings) => {
return getPageAsyncIterator(pagedResult, settings === null || settings === void 0 ? void 0 : settings.maxPageSize);
})
};
}
function getItemAsyncIterator(pagedResult, maxPageSize) {
return tslib.__asyncGenerator(this, arguments, function* getItemAsyncIterator_1() {
var e_1, _a;
const pages = getPageAsyncIterator(pagedResult, maxPageSize);
const firstVal = yield tslib.__await(pages.next());
// if the result does not have an array shape, i.e. TPage = TElement, then we return it as is
if (!Array.isArray(firstVal.value)) {
yield yield tslib.__await(firstVal.value);
// `pages` is of type `AsyncIterableIterator<TPage>` but TPage = TElement in this case
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(pages)));
}
else {
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(firstVal.value)));
try {
for (var pages_1 = tslib.__asyncValues(pages), pages_1_1; pages_1_1 = yield tslib.__await(pages_1.next()), !pages_1_1.done;) {
const page = pages_1_1.value;
// pages is of type `AsyncIterableIterator<TPage>` so `page` is of type `TPage`. In this branch,
// it must be the case that `TPage = TElement[]`
yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (pages_1_1 && !pages_1_1.done && (_a = pages_1.return)) yield tslib.__await(_a.call(pages_1));
}
finally { if (e_1) throw e_1.error; }
}
}
});
}
function getPageAsyncIterator(pagedResult, maxPageSize) {
return tslib.__asyncGenerator(this, arguments, function* getPageAsyncIterator_1() {
let response = yield tslib.__await(pagedResult.getPage(pagedResult.firstPageLink, maxPageSize));
yield yield tslib.__await(response.page);
while (response.nextPageLink) {
response = yield tslib.__await(pagedResult.getPage(response.nextPageLink, maxPageSize));
yield yield tslib.__await(response.page);
}
});
}
exports.getPagedAsyncIterator = getPagedAsyncIterator;
//# sourceMappingURL=index.js.map

@@ -5,3 +5,3 @@ {

"sdk-type": "client",
"version": "1.1.4-alpha.20210729.2",
"version": "1.2.0-alpha.20210811.3",
"description": "Core types for paging async iterable iterators",

@@ -49,7 +49,9 @@ "tags": [

"build:test": "echo skipped",
"build": "tsc -p tsconfig.json && tsc -p tsconfig.es.json",
"build:types": "downlevel-dts types/latest/ types/3.1/",
"build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local && npm run build:types",
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-* temp *.tgz *.log",
"clean": "rimraf dist dist-* temp *.tgz types *.log",
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src",
"execute:samples": "echo skipped",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",

@@ -66,4 +68,4 @@ "integration-test:browser": "echo skipped",

"test": "npm run clean && tsc -p . && npm run unit-test:node && rollup -c 2>&1 && npm run unit-test:browser && npm run integration-test",
"unit-test:browser": "echo skipped",
"unit-test:node": "echo skipped",
"unit-test:browser": "karma start --single-run",
"unit-test:node": "mocha -r esm -r ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 50000 --full-trace --exclude \"test/**/browser/*.spec.ts\" \"test/**/*.spec.ts\"",
"unit-test": "npm run unit-test:node && npm run unit-test:browser"

@@ -74,10 +76,31 @@ },

"dependencies": {
"@azure/core-asynciterator-polyfill": "^1.0.0"
"@azure/core-asynciterator-polyfill": "^1.0.0",
"tslib": "^2.2.0"
},
"devDependencies": {
"@azure/dev-tool": "^1.0.0-alpha",
"@microsoft/api-extractor": "7.7.11",
"@azure/eslint-plugin-azure-sdk": "^3.0.0-alpha",
"@types/chai": "^4.1.6",
"@types/mocha": "^7.0.2",
"@types/node": "^12.0.0",
"chai": "^4.2.0",
"downlevel-dts": "~0.4.0",
"eslint": "^7.15.0",
"karma": "^6.2.0",
"karma-chrome-launcher": "^3.0.0",
"karma-coverage": "^2.0.0",
"karma-edge-launcher": "^0.4.2",
"karma-env-preprocessor": "^0.1.1",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-junit-reporter": "^2.0.1",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-sourcemap-loader": "^0.3.8",
"mocha": "^7.1.1",
"mocha-junit-reporter": "^1.18.0",
"prettier": "^1.16.4",
"rimraf": "^3.0.0",
"rollup": "^1.16.3",
"typescript": "~4.2.0",

@@ -84,0 +107,0 @@ "typedoc": "0.15.2"

@@ -1,33 +0,60 @@

import "@azure/core-asynciterator-polyfill";
/**
* @interface
* An interface that tracks the settings for paged iteration
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
export interface PageSettings {
export declare function getPagedAsyncIterator<TElement, TPage = TElement[], TPageSettings = PageSettings>(pagedResult: PagedResult<TPage, TPageSettings>): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* An interface that allows async iterable iteration both to completion and by page.
*/
export declare interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {
/**
* @member {string} [continuationToken] The token that keeps track of where to continue the iterator
* The next method, part of the iteration protocol
*/
continuationToken?: string;
next(): Promise<IteratorResult<T, T>>;
/**
* @member {number} [pageSize] The size of the page during paged iteration
* The connection to the async iterator, part of the iteration protocol
*/
maxPageSize?: number;
[Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;
}
/**
* @interface
* An interface that allows async iterable iteration both to completion and by page.
* An interface that describes how to communicate with the service.
*/
export interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {
export declare interface PagedResult<TPage, TPageSettings = PageSettings> {
/**
* @member {Promise} [next] The next method, part of the iteration protocol
* Link to the first page of results.
*/
next(): Promise<IteratorResult<T>>;
firstPageLink: string;
/**
* @member {Symbol} [asyncIterator] The connection to the async iterator, part of the iteration protocol
* A method that returns a page of results.
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;
getPage: (pageLink: string, maxPageSize?: number) => Promise<{
page: TPage;
nextPageLink?: string;
}>;
/**
* @member {Function} [byPage] Return an AsyncIterableIterator that works a page at a time
* a function to implement the `byPage` method on the paged async iterator. The default is
* one that sets the `maxPageSizeParam` from `settings.maxPageSize`.
*/
byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
}
/**
* An interface that tracks the settings for paged iteration
*/
export declare interface PageSettings {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
/**
* The size of the page during paged iteration
*/
maxPageSize?: number;
}
export {};

@@ -1,33 +0,65 @@

import "@azure/core-asynciterator-polyfill";
/**
* @interface
* An interface that tracks the settings for paged iteration
* returns an async iterator that iterates over results. It also has a `byPage`
* method that returns pages of items at once.
*
* @param pagedResult - an object that specifies how to get pages.
* @returns a paged async iterator that iterates over results.
*/
export interface PageSettings {
/**
* @member {string} [continuationToken] The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
/**
* @member {number} [pageSize] The size of the page during paged iteration
*/
maxPageSize?: number;
}
export declare function getPagedAsyncIterator<TElement, TPage = TElement[], TPageSettings = PageSettings>(pagedResult: PagedResult<TPage, TPageSettings>): PagedAsyncIterableIterator<TElement, TPage, TPageSettings>;
/**
* @interface
* An interface that allows async iterable iteration both to completion and by page.
*/
export interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {
/**
* @member {Promise} [next] The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<T, T>>;
/**
* @member {Symbol} [asyncIterator] The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;
/**
* @member {Function} [byPage] Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;
export declare interface PagedAsyncIterableIterator<T, PageT = T[], PageSettingsT = PageSettings> {
/**
* The next method, part of the iteration protocol
*/
next(): Promise<IteratorResult<T, T>>;
/**
* The connection to the async iterator, part of the iteration protocol
*/
[Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT, PageSettingsT>;
/**
* Return an AsyncIterableIterator that works a page at a time
*/
byPage: (settings?: PageSettingsT) => AsyncIterableIterator<PageT>;
}
/**
* An interface that describes how to communicate with the service.
*/
export declare interface PagedResult<TPage, TPageSettings = PageSettings> {
/**
* Link to the first page of results.
*/
firstPageLink: string;
/**
* A method that returns a page of results.
*/
getPage: (pageLink: string, maxPageSize?: number) => Promise<{
page: TPage;
nextPageLink?: string;
}>;
/**
* a function to implement the `byPage` method on the paged async iterator. The default is
* one that sets the `maxPageSizeParam` from `settings.maxPageSize`.
*/
byPage?: (settings?: TPageSettings) => AsyncIterableIterator<TPage>;
}
/**
* An interface that tracks the settings for paged iteration
*/
export declare interface PageSettings {
/**
* The token that keeps track of where to continue the iterator
*/
continuationToken?: string;
/**
* The size of the page during paged iteration
*/
maxPageSize?: number;
}
export { }
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc