2019-12-30 22:14:42 +03:00
# Azure Core Paging client library for JavaScript
2019-06-13 04:49:37 +03:00
2019-06-28 00:36:58 +03:00
This library provides core types for paging async iterable iterators.
2019-06-13 04:49:37 +03:00
## Getting started
### Installation
2019-06-28 00:36:58 +03:00
If using this as part of another project in the [azure-sdk-for-js ](https://github.com/Azure/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
2024-09-25 16:35:12 +03:00
```
2019-06-28 00:36:58 +03:00
npm install @azure/core -paging
```
2019-06-13 04:49:37 +03:00
## Key concepts
You can find an explanation of how this repository's code works by going to our [architecture overview ](https://github.com/Azure/ms-rest-js/blob/master/docs/architectureOverview.md ).
## Examples
Example of building with the types:
2024-09-25 16:35:12 +03:00
```typescript snippet:paging_example
2024-11-07 00:31:08 +03:00
import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
2024-09-25 16:35:12 +03:00
function listSecrets(
options: ListSecretsOptions = {},
): PagedAsyncIterableIterator< SecretAttributes > {
2024-11-07 00:31:08 +03:00
const iter = listSecretsAll(options);
2024-09-25 16:35:12 +03:00
return {
async next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
2024-11-07 00:31:08 +03:00
byPage: (settings: PageSettings = {}) => listSecretsPage(settings, options),
2024-09-25 16:35:12 +03:00
};
}
for await (const page of listSecrets().byPage({ maxPageSize: 2 })) {
for (const secret of page) {
console.log("secret: ", secret);
2019-06-13 04:49:37 +03:00
}
2024-09-25 16:35:12 +03:00
}
2019-06-13 04:49:37 +03:00
```
And using the types:
```
2020-02-28 00:22:28 +03:00
for await (let page of client.listSecrets().byPage({ maxPageSize: 2 })) {
2019-06-13 04:49:37 +03:00
for (const secret of page) {
console.log("secret: ", secret);
}
}
```
## Next steps
2019-06-28 00:36:58 +03:00
Try out this package in your application when dealing with async iterable iterators and provide feedback!
2019-06-13 04:49:37 +03:00
## Troubleshooting
2019-06-28 00:36:58 +03:00
Log an issue at https://github.com/Azure/azure-sdk-for-js/issues
2019-06-13 04:49:37 +03:00
2019-06-28 00:36:58 +03:00
## Contributing
2019-06-13 04:49:37 +03:00
2021-06-23 00:55:17 +03:00
If you'd like to contribute to this library, please read the [contributing guide ](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md ) to learn more about how to build and test the code.
2019-11-05 03:19:10 +03:00
![Impressions ](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-paging%2FREADME.png )