chore(deps): bump tiny-async-pool from 1.2.0 to 2.0.1 (#9350)

* chore(deps): bump tiny-async-pool from 1.2.0 to 2.0.1

Bumps [tiny-async-pool](https://github.com/rxaviers/async-pool) from 1.2.0 to 2.0.1.
- [Release notes](https://github.com/rxaviers/async-pool/releases)
- [Commits](https://github.com/rxaviers/async-pool/compare/v1.2.0...v2.0.1)

---
updated-dependencies:
- dependency-name: tiny-async-pool
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix(route): tiny-async-pool v2 compatibility, url.resolve

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: TonyRL <TonyRL@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2022-03-20 22:40:32 +08:00 committed by GitHub
parent 6477e6b8e4
commit db78d3d275
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 62 deletions

View File

@ -2,6 +2,7 @@ const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const asyncPool = require('tiny-async-pool');
const { parseDate } = require('@/utils/parse-date');
const baseUrl = 'http://www.biquge5200.com/';
// 获取小说的最新章节列表
@ -25,36 +26,36 @@ module.exports = async (ctx) => {
.map((_, e) => ({
title: e.children[0].data,
link: e.attribs.href,
pubDate: new Date((parseInt(e.attribs.href.split('/').pop().replace('.html', '')) - 15015015) * 10000).toUTCString(),
pubDate: parseDate((parseInt(e.attribs.href.split('/').pop().replace('.html', '')) - 15015015) * 10000),
}))
.get();
const items = await asyncPool(3, chapter_item, async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const items = [];
for await (const item of asyncPool(3, chapter_item, (item) =>
ctx.cache.tryGet(item, async () => {
const response = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const response = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const responseHtml = iconv.decode(response.data, 'GBK');
const $ = cheerio.load(responseHtml);
const responseHtml = iconv.decode(response.data, 'GBK');
const $ = cheerio.load(responseHtml);
const description = $('#content').html();
const description = $('#content').html();
const single = {
title: item.title,
description,
link: item.link,
pubDate: item.pubDate,
};
return single;
})
)) {
items.push(item);
}
const single = {
title: item.title,
description,
link: item.link,
pubDate: item.pubDate,
};
ctx.cache.set(item.link, JSON.stringify(single));
return Promise.resolve(single);
});
ctx.state.data = {
title: `笔趣阁 ${title}`,
link: `${baseUrl}${id}/`,

View File

@ -1,15 +1,15 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const url = require('url');
const asyncPool = require('tiny-async-pool');
const { parseDate } = require('@/utils/parse-date');
const firstDay = new Date('2020-01-01');
const baseUrl = 'http://www.biquge.info';
// 获取小说的最新章节列表
module.exports = async (ctx) => {
const { id, limit = 10 } = ctx.params; // 小说id
const pageUrl = url.resolve(baseUrl, `/${id}/`);
const pageUrl = new URL(`/${id}/`, baseUrl);
const response = await got({
method: 'get',
@ -28,37 +28,37 @@ module.exports = async (ctx) => {
.find('a')
.map((i, e) => ({
title: e.children[0].data,
link: url.resolve(pageUrl, e.attribs.href),
pubDate: new Date(firstDay.getTime() + (nItems - parseInt(limit) + i) * 1000 * 60 * 60 * 24),
link: new URL(e.attribs.href, pageUrl),
pubDate: parseDate(firstDay.getTime() + (nItems - parseInt(limit) + i) * 1000 * 60 * 60 * 24),
}))
.get();
const items = await asyncPool(3, chapter_item, async (item) => {
const cache = await ctx.cache.get(item.link);
if (cache) {
return Promise.resolve(JSON.parse(cache));
}
const items = [];
for await (const item of asyncPool(3, chapter_item, (item) =>
ctx.cache.tryGet(item, async () => {
const response = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const response = await got({
method: 'get',
url: item.link,
responseType: 'buffer',
});
const responseHtml = iconv.decode(response.data, 'utf-8');
const $ = cheerio.load(responseHtml);
const responseHtml = iconv.decode(response.data, 'utf-8');
const $ = cheerio.load(responseHtml);
const description = $('#content').html();
const description = $('#content').html();
const single = {
title: item.title,
description,
link: item.link,
pubDate: item.pubDate,
};
return single;
})
)) {
items.push(item);
}
const single = {
title: item.title,
description,
link: item.link,
pubDate: item.pubDate,
};
ctx.cache.set(item.link, JSON.stringify(single));
return Promise.resolve(single);
});
ctx.state.data = {
title: `笔趣阁 ${title}`,
link: pageUrl,

View File

@ -126,7 +126,7 @@
"simplecc-wasm": "0.1.4",
"socks-proxy-agent": "6.1.1",
"string-similarity": "4.0.4",
"tiny-async-pool": "1.2.0",
"tiny-async-pool": "2.0.1",
"torrent-search-api": "2.1.4",
"tough-cookie": "4.0.0",
"tunnel": "0.0.6",

View File

@ -13014,13 +13014,10 @@ timsort@^0.3.0:
resolved "https://registry.yarnpkg.com/timsort/-/timsort-0.3.0.tgz#405411a8e7e6339fe64db9a234de11dc31e02bd4"
integrity sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=
tiny-async-pool@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/tiny-async-pool/-/tiny-async-pool-1.2.0.tgz#22132957e18f8b6020a94b390d07718fd519cc71"
integrity sha512-PY/OiSenYGBU3c1nTuP1HLKRkhKFDXsAibYI5GeHbHw2WVpt6OFzAPIRP94dGnS66Jhrkheim2CHAXUNI4XwMg==
dependencies:
semver "^5.5.0"
yaassertion "^1.0.0"
tiny-async-pool@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/tiny-async-pool/-/tiny-async-pool-2.0.1.tgz#b91a5e9fa539f2d89b2201cd843a7341fe2710a7"
integrity sha512-QIXBQdZdFWb7sLsuS5R8+23YdUXypkplXG+C3AMkEVzUlAZ/2EWrQzfAey0l4/r8ih+F7KgbJdPWHrfOce908A==
tlds@1.224.0:
version "1.224.0"
@ -14482,11 +14479,6 @@ y18n@^5.0.5:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
yaassertion@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/yaassertion/-/yaassertion-1.0.2.tgz#f1a90166e1cc4ad44dbb71487009ebca017e9874"
integrity sha512-sBoJBg5vTr3lOpRX0yFD+tz7wv/l2UPMFthag4HGTMPrypBRKerjjS8jiEnNMjcAEtPXjbHiKE0UwRR1W1GXBg==
yallist@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"