Skip to content

Commit 9531cd7

Browse files
committed
ported to typescript
1 parent cc0a276 commit 9531cd7

File tree

11 files changed

+2976
-359
lines changed

11 files changed

+2976
-359
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules/
2+
dist/

README.md

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +0,0 @@
1-
# JSON FROM TABLE
2-
3-
Converts html tables to JSON and JS objects
4-
5-
[![NPM](https://nodei.co/npm/jsonfromtable.png)](https://nodei.co/npm/jsonfromtable/)
6-
7-
## Installation
8-
9-
Install via npm
10-
11-
```batch
12-
npm install jsonfromtable
13-
```
14-
15-
## Usage
16-
17-
```js
18-
const jsonfromtable = require('jsonfromtable')
19-
20-
jsonfromtable(options, headers).then((data) => {
21-
console.log(data)
22-
})
23-
```
24-
25-
`jsonfromtable` function takes two arguments `options` and `headers` and returns promise.
26-
27-
Check this [example](https://codesandbox.io/s/jsonfromtable-example-140hz) in codesandbox.
28-
29-
## Options
30-
31-
### url
32-
33-
If you want the output from a url then you need to pass `url` option. The url should be of a webpage which has a table.
34-
35-
```js
36-
options = {
37-
url: 'https://www.example.com',
38-
}
39-
```
40-
41-
### html
42-
43-
If you want the output from a html then you need to pass `html` option. The html should contain `table` tag.
44-
45-
```js
46-
options = {
47-
html: '<table>....</table>',
48-
}
49-
```
50-
51-
### format
52-
53-
If you want the json output then you can pass `format` option.
54-
55-
```js
56-
options = {
57-
url: 'https://www.example.com',
58-
format: 'json', // default => jsobject
59-
}
60-
```
61-
62-
### selector
63-
64-
If the page has more than one table, then you can pass id of the table as `selector`.
65-
66-
```js
67-
options = {
68-
url: 'https://www.example.com',
69-
selector: '#table_example', // default => table
70-
}
71-
```
72-
73-
<br />
74-
75-
## Headers
76-
77-
The first row from table is taken a key. You can also pass your own headers
78-
79-
```js
80-
options = {
81-
url: 'https://www.example.com',
82-
selector: '#table_example', // default => table
83-
headers: ['header1', 'header2', 'header3'],
84-
}
85-
```
86-
87-
## License
88-
89-
MIT

index.js

Lines changed: 0 additions & 44 deletions
This file was deleted.

package-lock.json

Lines changed: 0 additions & 155 deletions
This file was deleted.

package.json

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
11
{
22
"name": "jsonfromtable",
3-
"version": "1.1.0",
4-
"description": "Generate json output from html tables",
3+
"version": "1.0.0",
4+
"description": "Generate json from table table",
55
"main": "index.js",
6+
"scripts": {
7+
"watch": "tsc -w",
8+
"build": "tsc"
9+
},
610
"repository": {
711
"type": "git",
8-
"url": "git+https://github.com/acharyaroshanji/jsonfromtable.git"
12+
"url": "git+https://github.com/coderosh/jsonfromtable.git"
913
},
10-
"keywords": [
11-
"table to json",
12-
"json",
13-
"html table",
14-
"table scraper",
15-
"table parser"
16-
],
17-
"author": "Roshan Acharya",
18-
"license": "MIT",
14+
"keywords": [],
15+
"author": "Roshan Acharya <acharyaroshan2357@gmail.com>",
16+
"license": "ISC",
1917
"bugs": {
20-
"url": "https://github.com/acharyaroshanji/jsonfromtable/issues"
18+
"url": "https://github.com/coderosh/jsonfromtable/issues"
19+
},
20+
"homepage": "https://github.com/coderosh/jsonfromtable#readme",
21+
"devDependencies": {
22+
"@types/jest": "^26.0.23",
23+
"@types/node": "^15.12.4",
24+
"jest": "^27.0.4",
25+
"ts-jest": "^27.0.3",
26+
"ts-node": "^10.0.0",
27+
"typescript": "^4.3.4"
2128
},
22-
"homepage": "https://github.com/acharyaroshanji/jsonfromtable#readme",
2329
"dependencies": {
24-
"cheerio": "^1.0.0-rc.3",
25-
"node-fetch": "^2.6.0"
30+
"cheerio": "^1.0.0-rc.10",
31+
"node-fetch": "^2.6.1"
2632
}
2733
}

0 commit comments

Comments
 (0)