unpdf 2.2.0 → 2.2.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.
Files changed (2) hide show
  1. package/dist/index.mjs +6 -3
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -584,7 +584,8 @@ function getCoverage(boxes, view) {
584
584
  // src/links.ts
585
585
  async function extractLinks(data) {
586
586
  return await withDocument(data, async (pdf) => {
587
- const links = await Promise.all(Array.from({ length: pdf.numPages }, (_, i) => getPageLinks(pdf, i + 1)));
587
+ const links = [];
588
+ for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++) links.push(await getPageLinks(pdf, pageNumber));
588
589
  return {
589
590
  totalPages: pdf.numPages,
590
591
  links
@@ -636,7 +637,8 @@ function parseISODateString(isoDateString) {
636
637
  // src/text.ts
637
638
  async function extractTextItems(data) {
638
639
  return await withDocument(data, async (pdf) => {
639
- const items = await Promise.all(Array.from({ length: pdf.numPages }, (_, i) => getPageTextItems(pdf, i + 1)));
640
+ const items = [];
641
+ for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++) items.push(await getPageTextItems(pdf, pageNumber));
640
642
  return {
641
643
  totalPages: pdf.numPages,
642
644
  items
@@ -664,7 +666,8 @@ async function getPageTextItems(document, pageNumber) {
664
666
  async function extractText(data, options = {}) {
665
667
  const { mergePages = false } = options;
666
668
  return await withDocument(data, async (pdf) => {
667
- const texts = await Promise.all(Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1)));
669
+ const texts = [];
670
+ for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++) texts.push(await getPageText(pdf, pageNumber));
668
671
  return {
669
672
  totalPages: pdf.numPages,
670
673
  text: mergePages ? normalizeMergedText(texts) : texts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unpdf",
3
3
  "type": "module",
4
- "version": "2.2.0",
4
+ "version": "2.2.1",
5
5
  "description": "PDF extraction and rendering across all JavaScript runtimes",
6
6
  "author": "Johann Schopplich <hello@johannschopplich.com>",
7
7
  "license": "MIT",