@octokit/plugin-paginate-rest
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -5,3 +5,3 @@ 'use strict'; | ||
const VERSION = "2.4.0"; | ||
const VERSION = "2.5.0"; | ||
@@ -59,22 +59,19 @@ /** | ||
[Symbol.asyncIterator]: () => ({ | ||
next() { | ||
if (!url) { | ||
return Promise.resolve({ | ||
done: true | ||
}); | ||
} | ||
return requestMethod({ | ||
async next() { | ||
if (!url) return { | ||
done: true | ||
}; | ||
const response = await requestMethod({ | ||
method, | ||
url, | ||
headers | ||
}).then(normalizePaginatedListResponse).then(response => { | ||
// `response.headers.link` format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
// sets `url` to undefined if "next" URL is not present or `link` header is not set | ||
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; | ||
return { | ||
value: response | ||
}; | ||
}); | ||
const normalizedResponse = normalizePaginatedListResponse(response); // `response.headers.link` format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
// sets `url` to undefined if "next" URL is not present or `link` header is not set | ||
url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; | ||
return { | ||
value: normalizedResponse | ||
}; | ||
} | ||
@@ -117,2 +114,6 @@ | ||
const composePaginateRest = Object.assign(paginate, { | ||
iterator | ||
}); | ||
/** | ||
@@ -132,3 +133,4 @@ * @param octokit Octokit instance | ||
exports.composePaginateRest = composePaginateRest; | ||
exports.paginateRest = paginateRest; | ||
//# sourceMappingURL=index.js.map |
import { VERSION } from "./version"; | ||
import { paginate } from "./paginate"; | ||
import { iterator } from "./iterator"; | ||
export { composePaginateRest } from "./compose-paginate"; | ||
/** | ||
@@ -5,0 +6,0 @@ * @param octokit Octokit instance |
@@ -12,15 +12,12 @@ import { normalizePaginatedListResponse } from "./normalize-paginated-list-response"; | ||
[Symbol.asyncIterator]: () => ({ | ||
next() { | ||
if (!url) { | ||
return Promise.resolve({ done: true }); | ||
} | ||
return requestMethod({ method, url, headers }) | ||
.then(normalizePaginatedListResponse) | ||
.then((response) => { | ||
// `response.headers.link` format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
// sets `url` to undefined if "next" URL is not present or `link` header is not set | ||
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; | ||
return { value: response }; | ||
}); | ||
async next() { | ||
if (!url) | ||
return { done: true }; | ||
const response = await requestMethod({ method, url, headers }); | ||
const normalizedResponse = normalizePaginatedListResponse(response); | ||
// `response.headers.link` format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
// sets `url` to undefined if "next" URL is not present or `link` header is not set | ||
url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; | ||
return { value: normalizedResponse }; | ||
}, | ||
@@ -27,0 +24,0 @@ }), |
@@ -1,1 +0,1 @@ | ||
export const VERSION = "2.4.0"; | ||
export const VERSION = "2.5.0"; |
@@ -0,4 +1,5 @@ | ||
import { Octokit } from "@octokit/core"; | ||
import { PaginateInterface } from "./types"; | ||
export { PaginateInterface } from "./types"; | ||
import { Octokit } from "@octokit/core"; | ||
export { composePaginateRest } from "./compose-paginate"; | ||
/** | ||
@@ -5,0 +6,0 @@ * @param octokit Octokit instance |
import { Octokit } from "@octokit/core"; | ||
import { RequestInterface, OctokitResponse, RequestParameters, Route } from "./types"; | ||
import { RequestInterface, RequestParameters, Route } from "./types"; | ||
export declare function iterator(octokit: Octokit, route: Route | RequestInterface, parameters?: RequestParameters): { | ||
@@ -7,6 +7,8 @@ [Symbol.asyncIterator]: () => { | ||
done: boolean; | ||
}> | Promise<{ | ||
value: OctokitResponse<any>; | ||
value?: undefined; | ||
} | { | ||
value: import("@octokit/types/dist-types/OctokitResponse").OctokitResponse<any>; | ||
done?: undefined; | ||
}>; | ||
}; | ||
}; |
@@ -1,1 +0,1 @@ | ||
export declare const VERSION = "2.4.0"; | ||
export declare const VERSION = "2.5.0"; |
@@ -1,2 +0,2 @@ | ||
const VERSION = "2.4.0"; | ||
const VERSION = "2.5.0"; | ||
@@ -54,15 +54,12 @@ /** | ||
[Symbol.asyncIterator]: () => ({ | ||
next() { | ||
if (!url) { | ||
return Promise.resolve({ done: true }); | ||
} | ||
return requestMethod({ method, url, headers }) | ||
.then(normalizePaginatedListResponse) | ||
.then((response) => { | ||
// `response.headers.link` format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
// sets `url` to undefined if "next" URL is not present or `link` header is not set | ||
url = ((response.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; | ||
return { value: response }; | ||
}); | ||
async next() { | ||
if (!url) | ||
return { done: true }; | ||
const response = await requestMethod({ method, url, headers }); | ||
const normalizedResponse = normalizePaginatedListResponse(response); | ||
// `response.headers.link` format: | ||
// '<https://api.github.com/users/aseemk/followers?page=2>; rel="next", <https://api.github.com/users/aseemk/followers?page=2>; rel="last"' | ||
// sets `url` to undefined if "next" URL is not present or `link` header is not set | ||
url = ((normalizedResponse.headers.link || "").match(/<([^>]+)>;\s*rel="next"/) || [])[1]; | ||
return { value: normalizedResponse }; | ||
}, | ||
@@ -97,2 +94,4 @@ }), | ||
const composePaginateRest = Object.assign(paginate, { iterator }); | ||
/** | ||
@@ -111,3 +110,3 @@ * @param octokit Octokit instance | ||
export { paginateRest }; | ||
export { composePaginateRest, paginateRest }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@octokit/plugin-paginate-rest", | ||
"description": "Octokit plugin to paginate REST API endpoint responses", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112369
23
1793