Comparing version 0.5.0 to 0.6.0
{ | ||
"name": "reddit-ts", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Reddit API written in Typescript", | ||
@@ -5,0 +5,0 @@ "author": "aelesia", |
@@ -174,3 +174,4 @@ "use strict"; | ||
}; | ||
RedditAPI.prototype.search_all = function (username) { | ||
RedditAPI.prototype.search_all = function (username, max_results) { | ||
if (max_results === void 0) { max_results = 999; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -195,3 +196,3 @@ var _this = this; | ||
case 3: | ||
if (data.data.after) return [3, 1]; | ||
if (data.data.after && all_posts.length < max_results) return [3, 1]; | ||
_c.label = 4; | ||
@@ -198,0 +199,0 @@ case 4: return [2, all_posts]; |
@@ -198,3 +198,15 @@ "use strict"; | ||
}); }); | ||
test('Search Max Posts 100', function () { return __awaiter(void 0, void 0, void 0, function () { | ||
var results; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4, Reddit.search_all('aelesia-', 100)]; | ||
case 1: | ||
results = _a.sent(); | ||
expect(results.length).toBeLessThanOrEqual(100); | ||
return [2]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
//# sourceMappingURL=RedditAPI.test.js.map |
{ | ||
"name": "reddit-ts", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Reddit API written in Typescript", | ||
@@ -5,0 +5,0 @@ "author": "aelesia", |
@@ -93,3 +93,3 @@ import { Comments } from './types/Comments.type' | ||
async search_all(username: string): Promise<Post[]> { | ||
async search_all(username: string, max_results = 999): Promise<Post[]> { | ||
return await this.trycatch<Post[]>(async () => { | ||
@@ -102,3 +102,3 @@ let data: Search | undefined | ||
all_posts = all_posts.concat(map) | ||
} while (data.data.after) | ||
} while (data.data.after && all_posts.length < max_results) | ||
@@ -105,0 +105,0 @@ return all_posts |
@@ -110,2 +110,7 @@ import RedditAPI from '../src/RedditAPI' | ||
test('Search Max Posts 100', async () => { | ||
let results = await Reddit.search_all('aelesia-', 100) | ||
expect(results.length).toBeLessThanOrEqual(100) | ||
}) | ||
// describe('reply search delete', () => { | ||
@@ -112,0 +117,0 @@ // let id = '' |
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
95040
1856