@zenghongtu/any-text
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

Any-Text

Extract text content from a file.

Supported File Extensions

  • DOC
  • DOCX
  • DOT
  • PDF
  • CSV
  • TXT
  • XLS
  • XLSX
  • JSON

How to use

  • Install the library as a dependency (/dev-dependency)
npm i -D any-text
  • Make use of the getText method to read the text content
var reader = require('any-text');

reader
  .getText(`path-to-file`)
  .then(function (data) {
    console.log(data); // handle success
  })
  .catch(function (error) {
    console.log(error); // handle error
  });
  • You can also use the async/await notation
var reader = require('any-text');

const text = await reader.getText(`path-to-file`);

console.log(text);

Sample Test

var reader = require('any-text');

const chai = require('chai');
const expect = chai.expect;

describe('file reader checks', () => {
  it('check docx file content', async () => {
    expect(await reader.getText(`${process.cwd()}/test/files/dummy.docx`)).to.contains(
      'Lorem ipsum'
    );
  });
});

Tell me your issues

you can raise any issue here

Contribution

Any pull request is welcome.

If it works for you , give a Star! ⭐

- Copyright © 2020- Abhinaba Ghosh

Package Sidebar

Install

npm i @zenghongtu/any-text

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

6.47 kB

Total Files

7

Last publish

Collaborators

  • zenghongtu