Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@arbs.io/asset-extractor-wasm

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arbs.io/asset-extractor-wasm

This npm package offers a straightforward method to extract text content from various binary and text file formats. The package comes with a pre-built configuration that works out-of-the-box, requiring no additional setup. It is designed for use in Browse

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
increased by211.11%
Maintainers
1
Weekly downloads
 
Created
Source

asset-extractor-wasm

Caution: This package is currently in development and should be treated as a preview release (pre-v1.0)

Welcome to @arbs.io/asset-extractor-wasm, a powerful npm package that provides a straightforward method to extract content from a wide range of binary and text file formats. This package is pre-configured to work seamlessly, requiring no additional setup. It is designed to be compatible with both Browsers and Node.js environments, including Visual Studio Code extensions, making it a versatile tool for your development needs.

Features

Supported File Types

The current version of the package supports content extraction from an extensive list of MIME types, including but not limited to:

TextMediaextensionMimetype
txttext/plain
docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
🔲🔲xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
odpapplication/vnd.oasis.opendocument.presentation
odsapplication/vnd.oasis.opendocument.spreadsheet
odtapplication/vnd.oasis.opendocument.text
🔲xmltext/xml
🔲pdfapplication/pdf
🔲htmltext/html
🔲epubapplication/epub+zip
🔲mobiapplication/x-mobipocket-ebook
Legend

✅: Completed 🔲: Coming soon ⚫: Not Applicable

  • Text: Extract Text
  • Media: Extract Image/Video/Audio

Requesting Additional File Support

We are always looking to expand the capabilities of @arbs.io/asset-extractor-wasm. If you need support for additional file formats, please submit an enhancement issue on the project's repository. We value your feedback and contributions as they help us improve this package for the broader developer community.

Installation

To install the package, use the following npm command:

npm install @arbs.io/asset-extractor-wasm

This command will add the package to your project's dependencies.

Usage

Here's an example of how to extract text from a buffer. If the file type is binary, the mime-type is verified using file-type.

import * as fs from 'fs'
import {
  createDocumentParser,
  getTextPlain,
} from '@arbs.io/asset-extractor-wasm'

export const documentParserExample = () => {
  const buf = fs.readFileSync(`./data_source/microservices.docx`)
  const documentParser = createDocumentParser(new Uint8Array(buf))

  console.log(`mimetype: (${documentParser?.mimetype})`)
  console.log(`extension: (${documentParser?.extension})`)
  console.log(`content [text/plain]: (${documentParser?.contents?.text!})`)
}

This example demonstrates how to read a file, convert it to a Uint8Array, and then extract the assets.

API

DocumentParser

The DocumentParser object provides the following properties:

  • mimetype: The mime-type of the buffer determined by the binary signature.
  • extension: The (file) extension of the buffer determined by the binary signature.
  • contents: An array of Content within the buffer (text, images, ...)
interface DocumentParser {
  mimetype: string
  extension: string
  contents: ParserContent | null
}

ParserContent

  • text: Text content of the buffer. There is only ever a single text content for each buffer.
  • media: Array of all embedded media assets with the buffer (images, audio, video, ...).
interface ParserContent {
  text: string | null
  media: ContentData[] | null
}

ContentData

  • identity: The identity of the binary embedded object. For example: image1.png
  • mimetype: The mime-type is set to the format of the data send to the function. For example: image/png
  • data: The raw data base64 of the image binary format
interface ContentData {
  identity: string
  mimetype: string
  data: string
}

We hope you find @arbs.io/asset-extractor-wasm useful for your projects. If you have any questions, issues, or suggestions, please feel free to open an issue on our GitHub repository. We appreciate your support and are committed to making this package even better for the developer community.

Keywords

FAQs

Package last updated on 14 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc