azure-sdk-for-js/sdk/core/core-paging
Jeremy Meng cf8d25ff5e
Fix compiler errors in tests and samples (#31649)
After moving to ESM/tshy, we no longer build tests/samples. This PR
enables running "typecheck" as an optional rush bulk command, and fixes
some of the errors found.

The known errors reported on files from vite/vitest/chai are ignored.

The update-snippets dev-tool command throws error of reading undefined
in some cases, adding a null check fixes it.

Snippets are updated as well after snippets.spec.ts files are fixed.
2024-11-06 13:31:08 -08:00
..
config [EngSys] Enable Rush build cache for for common packages (#27409) 2023-10-19 14:22:44 -07:00
review add-type-from-cadl-azure-core (#23906) 2023-02-01 13:48:14 +08:00
samples/v1 [EngSys] move to vendored version of cross-env via dev-tool 2024-11-02 00:48:06 +00:00
samples-dev [core-paging] Use a TS v3.4-friendly iterator protocol (#19507) 2022-01-04 19:35:12 -05:00
src [eslint-plugin] add rule "@typescript-eslint/consistent-type-imports": "warn" 2024-10-30 15:48:52 +00:00
test Fix compiler errors in tests and samples (#31649) 2024-11-06 13:31:08 -08:00
CHANGELOG.md Post release automated changes for core releases (#29269) 2024-04-11 13:46:11 -04:00
LICENSE Use inlineSources to bundle source file contents inside map files (#7615) 2020-03-11 10:34:37 -07:00
README.md Fix compiler errors in tests and samples (#31649) 2024-11-06 13:31:08 -08:00
api-extractor.json [core] Upgrade to ES-Modules for core (#26238) 2024-02-20 17:42:23 +00:00
package.json [EngSys] use vendored version of `mkdirp` and `rimraf` from dev-tool 2024-10-23 17:53:07 +00:00
sample.env [core-paging] Use a TS v3.4-friendly iterator protocol (#19507) 2022-01-04 19:35:12 -05:00
tsconfig.browser.config.json [core] Add README snippets for core (#31204) 2024-09-25 09:35:12 -04:00
tsconfig.json [core] Add README snippets for core (#31204) 2024-09-25 09:35:12 -04:00
vitest.browser.config.ts [core] Add README snippets for core (#31204) 2024-09-25 09:35:12 -04:00
vitest.config.ts [core] Add README snippets for core (#31204) 2024-09-25 09:35:12 -04:00

README.md

Azure Core Paging client library for JavaScript

This library provides core types for paging async iterable iterators.

Getting started

Installation

If using this as part of another project in the azure-sdk-for-js repo, then run rush install after cloning the repo.

Otherwise, use npm to install this package in your application as follows

npm install @azure/core-paging

Key concepts

You can find an explanation of how this repository's code works by going to our architecture overview.

Examples

Example of building with the types:

import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";

function listSecrets(
  options: ListSecretsOptions = {},
): PagedAsyncIterableIterator<SecretAttributes> {
  const iter = listSecretsAll(options);
  return {
    async next() {
      return iter.next();
    },
    [Symbol.asyncIterator]() {
      return this;
    },
    byPage: (settings: PageSettings = {}) => listSecretsPage(settings, options),
  };
}
for await (const page of listSecrets().byPage({ maxPageSize: 2 })) {
  for (const secret of page) {
    console.log("secret: ", secret);
  }
}

And using the types:

  for await (let page of client.listSecrets().byPage({ maxPageSize: 2 })) {
    for (const secret of page) {
      console.log("secret: ", secret);
    }
  }

Next steps

Try out this package in your application when dealing with async iterable iterators and provide feedback!

Troubleshooting

Log an issue at https://github.com/Azure/azure-sdk-for-js/issues

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

Impressions