maugenst / tabletojson

An npm module for node.js to convert HTML tables to JSON objects
https://www.npmjs.com/package/tabletojson
MIT License
138 stars 38 forks source link

Error "tabletojson.convert is not a function" in v2.0.0 #50

Closed aarongoldenthal closed 4 years ago

aarongoldenthal commented 4 years ago

Running legacy code that previously worked with v1.2.0, e.g.

const tabletojson = require('tabletojson');
const result = tabletojson.convert(html);

results in TypeError: tabletojson.convert is not a function. It appears in v2.0.0 there is no default export, only the Tabletojson property, so this code must be changed as follows:

const tabletojson = require('tabletojson').Tabletojson;
const result = tabletojson.convert(html);

or

const { Tabletojson } = require('tabletojson');
const result = Tabletojson.convert(html);

This does not appear to be intentional as none of the examples were updated.

piranna commented 4 years ago

I'm facing the same problem, this is because code now is exporting a class with static methods, probably due to usage of Typescript. It should be exporting just only the methods. Typescript building is failling to me too.

maugenst commented 4 years ago

I'm currently working on a fix for this issue.

piranna commented 4 years ago

I'm currently working on a fix for this issue.

Cool! :-D I have been reviewing and fixing some linting issues, I'm going to create a pull-request right now :-)

maugenst commented 4 years ago

nice ... thx !!!

maugenst commented 4 years ago

I've just created a mock since the spawned express server doesn't work in travis :-(

piranna commented 4 years ago

You have the pull-request at https://github.com/maugenst/tabletojson/pull/51 :-)

maugenst commented 4 years ago

I changed the README.md to reflect the new api import.

piranna commented 4 years ago

I changed the README.md to reflect the new api import.

Good thing, thanks :-)