Skip to content

Commit

Permalink
0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
victornpb committed May 15, 2022
1 parent 8877de9 commit 6755c25
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
14 changes: 9 additions & 5 deletions dist/action.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* NotionJAM v0.0.8 (https://github.com/victornpb/notion-jam)
* NotionJAM v0.0.9 (https://github.com/victornpb/notion-jam)
* Copyright (c) victornpb
* @license UNLICENSED
*/
Expand Down Expand Up @@ -238,21 +238,25 @@ function plugin$1(frontmatter) {
function parallel(items, handler, concurrency) {
if (!Number.isInteger(concurrency) || concurrency < 1)
throw new Error('concurrency must be a positive integer greater than 0');

if (items.length === 0) return Promise.resolve([]);
return new Promise((resolve, reject) => {
const results = [];
let i = 0;

const next = (result) => {
results.push(result);
if (i < items.length) {
handler(items[i++]).then(next).catch(reject);
try {
handler(items[i++]).then(next).catch(reject);
} catch (err) { reject(err); }
}
else if (results.length === items.length) resolve(results);
};

for (let x = 0; x < Math.min(concurrency, items.length); x++) {
handler(items[i++]).then(next).catch(reject);
try {
handler(items[i++]).then(next).catch(reject);
} catch (err) { reject(err); break; }
}
});
}
Expand Down Expand Up @@ -562,7 +566,7 @@ async function run(options) {
filterValues: 'Ready,Published',
caseType: 'snake',

parallelPages: 3,
parallelPages: 25,
parallelDownloadsPerPage: 3,
downloadImageTimeout: 30,
skipDownloadedImages: true,
Expand Down
16 changes: 10 additions & 6 deletions dist/cli.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

/*!
* NotionJAM v0.0.8 (https://github.com/victornpb/notion-jam)
* NotionJAM v0.0.9 (https://github.com/victornpb/notion-jam)
* Copyright (c) victornpb
* @license UNLICENSED
*/
Expand Down Expand Up @@ -239,21 +239,25 @@ function plugin$1(frontmatter) {
function parallel(items, handler, concurrency) {
if (!Number.isInteger(concurrency) || concurrency < 1)
throw new Error('concurrency must be a positive integer greater than 0');

if (items.length === 0) return Promise.resolve([]);
return new Promise((resolve, reject) => {
const results = [];
let i = 0;

const next = (result) => {
results.push(result);
if (i < items.length) {
handler(items[i++]).then(next).catch(reject);
try {
handler(items[i++]).then(next).catch(reject);
} catch (err) { reject(err); }
}
else if (results.length === items.length) resolve(results);
};

for (let x = 0; x < Math.min(concurrency, items.length); x++) {
handler(items[i++]).then(next).catch(reject);
try {
handler(items[i++]).then(next).catch(reject);
} catch (err) { reject(err); break; }
}
});
}
Expand Down Expand Up @@ -563,7 +567,7 @@ async function run(options) {
filterValues: 'Ready,Published',
caseType: 'snake',

parallelPages: 3,
parallelPages: 25,
parallelDownloadsPerPage: 3,
downloadImageTimeout: 30,
skipDownloadedImages: true,
Expand Down Expand Up @@ -614,7 +618,7 @@ dotenv.config();

async function main() {
try {
run({
await run({
notionSecret: process.env.NOTION_SECRET,
notionDatabase: process.env.NOTION_DATABASE,
filterProp: process.env.FILTER_PROP,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "notion-jam",
"nameFull": "NotionJAM",
"version": "0.0.8",
"version": "0.0.9",
"description": "A notion-jam cli / action",
"license": "UNLICENSED",
"engines": {
Expand Down

0 comments on commit 6755c25

Please sign in to comment.