@azure/core-paging 1.0.0-preview.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # Azure Core Paging client library for JS
2
+
3
+ This library provides core types for paging async iterable iterators.
4
+
5
+ ## Getting started
6
+
7
+ ### Installation
8
+
9
+ If using this as part of another project in the [azure-sdk-for-js](https://github.com/Azure/azure-sdk-for-js) repo,
10
+ then run `rush install` after cloning the repo.
11
+
12
+ Otherwise, use npm to install this package in your application as follows
13
+
14
+ ```javascript
15
+ npm install @azure/core-paging
16
+ ```
17
+
18
+ ## Key concepts
19
+
20
+ 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).
21
+
22
+ ## Examples
23
+
24
+ Example of building with the types:
25
+
26
+ ```typescript
27
+ public listSecrets(
28
+ options?: ListSecretsOptions
29
+ ): PagedAsyncIterableIterator<SecretAttributes> {
30
+ const iter = this.listSecretsAll(options);
31
+ return {
32
+ async next() {
33
+ const item = (await iter.next()).value;
34
+ return item ? { done: false, value: item } : { done: true, value: undefined };
35
+ },
36
+ [Symbol.asyncIterator]() { return this; },
37
+ byPage: (settings: PageSettings = {}) => this.listSecretsPage(settings, options),
38
+ };
39
+ }
40
+ ```
41
+
42
+ And using the types:
43
+
44
+ ```
45
+ for await (let page of client.listSecrets().byPage({ pageSize: 2 })) {
46
+ for (const secret of page) {
47
+ console.log("secret: ", secret);
48
+ }
49
+ }
50
+ ```
51
+
52
+ ## Next steps
53
+
54
+ Try out this package in your application when dealing with async iterable iterators and provide feedback!
55
+
56
+ ## Troubleshooting
57
+
58
+ Log an issue at https://github.com/Azure/azure-sdk-for-js/issues
59
+
60
+ ## Contributing
61
+
62
+ This project welcomes contributions and suggestions. Most contributions require you to agree to a
63
+ Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
64
+ the rights to use your contribution. For details, visit https://cla.microsoft.com.
65
+
66
+ When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
67
+ a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
68
+ provided by the bot. You will only need to do this once across all repos using our CLA.
69
+
70
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
71
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
72
+ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
@@ -0,0 +1,35 @@
1
+ Third Party Notices for ms-rest-js
2
+
3
+ This project incorporates material from the project(s) listed below (collectively, Third Party Code).
4
+ Microsoft, Inc. Microsoft is not the original author of the Third Party Code.
5
+ The original copyright notice and license, under which Microsoft received such Third Party Code,
6
+ are set out below. This Third Party Code is licensed to you under their original license terms set forth below.
7
+ Microsoft reserves all other rights not expressly granted, whether by implication, estoppel or otherwise.
8
+
9
+ 1. uuid (https://github.com/kelektiv/node-uuid)
10
+
11
+ %% uuid NOTICES AND INFORMATION BEGIN HERE
12
+ =========================================
13
+ The MIT License (MIT)
14
+
15
+ Copyright (c) 2010-2016 Robert Kieffer and other contributors
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
34
+ =========================================
35
+ END OF uuid NOTICES AND INFORMATION
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("@azure/core-asynciterator-polyfill");
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@azure/core-paging",
3
+ "author": {
4
+ "name": "Microsoft Corporation",
5
+ "email": "azsdkteam@microsoft.com",
6
+ "url": "https://github.com/Azure/azure-sdk-for-js"
7
+ },
8
+ "version": "1.0.0-preview.1",
9
+ "description": "Core types for paging async iterable iterators",
10
+ "tags": [
11
+ "microsoft",
12
+ "clientruntime"
13
+ ],
14
+ "keywords": [
15
+ "microsoft",
16
+ "clientruntime"
17
+ ],
18
+ "main": "./dist-esm/index.js",
19
+ "types": "./types/corePaging.d.ts",
20
+ "files": [
21
+ "types/*.d.ts",
22
+ "dist-esm/**/*.js",
23
+ "LICENSE",
24
+ "README.md",
25
+ "ThirdPartyNotices.txt"
26
+ ],
27
+ "license": "MIT",
28
+ "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-paging",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git@github.com:Azure/azure-sdk-for-js.git"
32
+ },
33
+ "bugs": {
34
+ "url": "http://github.com/Azure/azure-sdk-for-js/issues"
35
+ },
36
+ "scripts": {
37
+ "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
38
+ "build": "tsc -p .",
39
+ "build:test": "echo skipped",
40
+ "check-format": "prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
41
+ "clean": "echo skipped",
42
+ "format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
43
+ "integration-test:browser": "echo skipped",
44
+ "integration-test:node": "echo skipped",
45
+ "integration-test": "npm run integration-test:node && npm run integration-test:browser",
46
+ "lint": "eslint -c ../../.eslintrc.json src test --ext .ts -f node_modules/eslint-detailed-reporter/lib/detailed.js -o template-lintReport.html || exit 0",
47
+ "lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" -c ../../.eslintrc.json --fix --fix-type [problem,suggestion]",
48
+ "pack": "npm pack 2>&1",
49
+ "prebuild": "npm run clean",
50
+ "test:browser": "npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
51
+ "test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
52
+ "test": "npm run build:test && npm run unit-test && npm run integration-test",
53
+ "unit-test:browser": "echo skipped",
54
+ "unit-test:node": "echo skipped",
55
+ "unit-test": "npm run unit-test:node && npm run unit-test:browser"
56
+ },
57
+ "sideEffects": true,
58
+ "private": false,
59
+ "dependencies": {
60
+ "@azure/core-asynciterator-polyfill": "^1.0.0-preview.1"
61
+ },
62
+ "devDependencies": {
63
+ "@types/node": "^8.0.0",
64
+ "@typescript-eslint/eslint-plugin": "~1.9.0",
65
+ "@typescript-eslint/parser": "^1.7.0",
66
+ "eslint": "^5.16.0",
67
+ "eslint-config-prettier": "^4.2.0",
68
+ "eslint-detailed-reporter": "^0.8.0",
69
+ "eslint-plugin-no-null": "^1.0.2",
70
+ "eslint-plugin-no-only-tests": "^2.3.0",
71
+ "eslint-plugin-promise": "^4.1.1",
72
+ "prettier": "^1.16.4",
73
+ "typescript": "^3.2.2"
74
+ }
75
+ }
@@ -0,0 +1,36 @@
1
+ import "@azure/core-asynciterator-polyfill";
2
+ /**
3
+ * @interface
4
+ * An interface that tracks the settings for paged iteration
5
+ */
6
+ export interface PageSettings {
7
+ /**
8
+ * @member {string} [continuationToken] The token that keeps track of where to continue the iterator
9
+ */
10
+ continuationToken?: string;
11
+ /**
12
+ * @member {number} [pageSize] The size of the page during paged iteration
13
+ */
14
+ maxPageSize?: number;
15
+ }
16
+ /**
17
+ * @interface
18
+ * An interface that allows async iterable iteration both to completion and by page.
19
+ */
20
+ export interface PagedAsyncIterableIterator<T, PageT = never> {
21
+ /**
22
+ * @member {Promise} [next] The next method, part of the iteration protocol
23
+ */
24
+ next(): Promise<{
25
+ done: boolean;
26
+ value: T;
27
+ }>;
28
+ /**
29
+ * @member {Symbol} [asyncIterator] The connection to the async iterator, part of the iteration protocol
30
+ */
31
+ [Symbol.asyncIterator](): PagedAsyncIterableIterator<T, PageT>;
32
+ /**
33
+ * @member {Function} [byPage] Return an AsyncIterableIterator that works a page at a time
34
+ */
35
+ byPage: (settings?: PageSettings) => AsyncIterableIterator<PageT extends never ? T[] : PageT>;
36
+ }