Skip to content

Commit

Permalink
docs(readme): update usage and installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
gamemaker1 committed Jul 10, 2023
1 parent 209c3fb commit 9fcd1ed
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ This module also uses:
- [`js-yaml`](https://www.npmjs.com/package/js-yaml) - to convert JSON into YAML
- [`file-type`](https://www.npmjs.com/package/file-type) - to detect the mime
type of files
- [`decompress`](https://www.npmjs.com/package/decompress) - to unzip files
- [`read-chunk`](https://www.npmjs.com/package/read-chunk) - to read chunks of
data from large files
- [`fflate`](https://www.npmjs.com/package/fflate) - to unzip files

A big thank you to the contributors of these projects!

## Installation

#### NodeJs

> **Note**
>
> This package is now pure ESM (from version 2.0.0 onwards). Please read
Expand All @@ -67,26 +67,32 @@ To use this in an Node project, install it using `npm`/`pnpm`/`yarn`:
> yarn add office-text-extractor
```

#### Browser

To use this package in the browser, fetch it using your preferred CDN:

```tsx
<script src="https://unpkg.com/office-text-extractor@latest/build/index.js"></script>
```

## Usage

```js
import { extractText } from 'office-text-extractor'
```ts
import { getTextExtractor } from 'office-text-extractor'

// Extract the text using `async-await`.
const text = await extractText('path/to/file')
console.log(text)
// Create a new instance of the extractor.
const extractor = getTextExtractor()

// Extract the text using Promises.
extractText('path/to/file')
.then((text) => console.log(text))
.catch((error) => console.error(error))
```
// Extract text from a URL, file or buffer.
const location =
'https://raw.githubusercontent.com/gamemaker1/office-text-extractor/rewrite/test/fixtures/docs/pptx.pptx'
const text = await extractor.extractText({
input: location, // this can be a file path or a buffer
type: 'url', // this is can be 'url', 'file' or 'buffer'
})

> **Note**
>
> There is no support for browser environments yet. If you want to add support,
> please feel free to
> [open a pull request](https://github.com/gamemaker1/office-text-extractor/pulls).
console.log(text)
```

## License

Expand Down

0 comments on commit 9fcd1ed

Please sign in to comment.