@eredzik/calaminejs 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +103 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @calaminejs/core
|
|
2
|
+
|
|
3
|
+
Rust [calamine](https://github.com/tafia/calamine) library bindings for JavaScript/TypeScript. Read Excel files (.xlsx, .xls) and convert them to Parquet format in both Node.js and browser environments.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @calaminejs/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 🚀 **Fast**: Powered by Rust and WebAssembly
|
|
14
|
+
- 📦 **Cross-platform**: Works in Node.js and browsers
|
|
15
|
+
- 🔷 **TypeScript**: Full TypeScript support
|
|
16
|
+
- 📊 **Excel Support**: Read `.xlsx` and `.xls` files
|
|
17
|
+
- 🗜️ **Parquet Export**: Efficient conversion to Parquet format
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Node.js
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import init, { Workbook } from '@calaminejs/core';
|
|
25
|
+
// or
|
|
26
|
+
const { default: init, Workbook } = require('@calaminejs/core');
|
|
27
|
+
|
|
28
|
+
await init();
|
|
29
|
+
const data = new Uint8Array(/* Excel file bytes */);
|
|
30
|
+
const workbook = Workbook.from_bytes(data);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Browser / ESM
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
import init, { Workbook } from '@calaminejs/core/web';
|
|
37
|
+
|
|
38
|
+
await init();
|
|
39
|
+
const response = await fetch('data.xlsx');
|
|
40
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
41
|
+
const workbook = Workbook.from_bytes(new Uint8Array(arrayBuffer));
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### CommonJS (Node.js)
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
const { default: init, Workbook } = require('@calaminejs/core/node');
|
|
48
|
+
|
|
49
|
+
await init();
|
|
50
|
+
const fs = require('fs');
|
|
51
|
+
const data = fs.readFileSync('data.xlsx');
|
|
52
|
+
const workbook = Workbook.from_bytes(new Uint8Array(data));
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## API
|
|
56
|
+
|
|
57
|
+
### `Workbook`
|
|
58
|
+
|
|
59
|
+
- `from_bytes(data: Uint8Array): Workbook` - Create workbook from bytes
|
|
60
|
+
- `sheet_count(): number` - Get number of sheets
|
|
61
|
+
- `sheet_names(): string[]` - Get sheet names
|
|
62
|
+
- `get_sheet(name: string): Sheet | null` - Get sheet by name
|
|
63
|
+
- `get_sheet_by_index(index: number): Sheet | null` - Get sheet by index
|
|
64
|
+
|
|
65
|
+
### `Sheet`
|
|
66
|
+
|
|
67
|
+
- `name: string` - Sheet name
|
|
68
|
+
- `row_count(): number` - Number of rows
|
|
69
|
+
- `col_count(): number` - Number of columns
|
|
70
|
+
- `rows(): any[][]` - Get all rows as 2D array
|
|
71
|
+
- `get_cell(row: number, col: number): CellValue | null` - Get cell value
|
|
72
|
+
- `to_parquet(): Uint8Array` - Convert to Parquet (auto column names)
|
|
73
|
+
- `to_parquet_with_names(columnNames: string[]): Uint8Array` - Convert to Parquet with custom column names
|
|
74
|
+
|
|
75
|
+
### `CellValue`
|
|
76
|
+
|
|
77
|
+
- `is_empty: boolean` - Check if empty
|
|
78
|
+
- `is_string: boolean` - Check if string
|
|
79
|
+
- `is_float: boolean` - Check if float
|
|
80
|
+
- `is_int: boolean` - Check if integer
|
|
81
|
+
- `is_bool: boolean` - Check if boolean
|
|
82
|
+
- `to_string_value(): string | null` - Get as string
|
|
83
|
+
- `to_float_value(): number | null` - Get as float
|
|
84
|
+
- `to_int_value(): number | null` - Get as integer
|
|
85
|
+
- `to_bool_value(): boolean | null` - Get as boolean
|
|
86
|
+
|
|
87
|
+
## Building from Source
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Build for both Node.js and browser
|
|
91
|
+
npm run build
|
|
92
|
+
|
|
93
|
+
# Build for Node.js only
|
|
94
|
+
npm run build:node
|
|
95
|
+
|
|
96
|
+
# Build for browser only
|
|
97
|
+
npm run build:web
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
MIT
|
|
103
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eredzik/calaminejs",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rust calamine library bindings for JavaScript/TypeScript - Excel file reading and Parquet conversion",
|
|
5
|
+
"main": "./pkg-node/calamine_js.js",
|
|
6
|
+
"module": "./pkg-web/calamine_js.js",
|
|
7
|
+
"types": "./pkg-node/calamine_js.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./pkg-node/calamine_js.d.ts",
|
|
11
|
+
"node": {
|
|
12
|
+
"import": "./pkg-node/calamine_js.js",
|
|
13
|
+
"require": "./pkg-node/calamine_js.js"
|
|
14
|
+
},
|
|
15
|
+
"import": "./pkg-web/calamine_js.js",
|
|
16
|
+
"require": "./pkg-node/calamine_js.js",
|
|
17
|
+
"default": "./pkg-node/calamine_js.js"
|
|
18
|
+
},
|
|
19
|
+
"./node": {
|
|
20
|
+
"types": "./pkg-node/calamine_js.d.ts",
|
|
21
|
+
"import": "./pkg-node/calamine_js.js",
|
|
22
|
+
"require": "./pkg-node/calamine_js.js",
|
|
23
|
+
"default": "./pkg-node/calamine_js.js"
|
|
24
|
+
},
|
|
25
|
+
"./web": {
|
|
26
|
+
"types": "./pkg-web/calamine_js.d.ts",
|
|
27
|
+
"import": "./pkg-web/calamine_js.js",
|
|
28
|
+
"default": "./pkg-web/calamine_js.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"pkg-node",
|
|
34
|
+
"pkg-web",
|
|
35
|
+
"README.md",
|
|
36
|
+
"LICENSE"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "npm run build:node && npm run build:web && npm run verify",
|
|
40
|
+
"build:node": "wasm-pack build --target nodejs --out-dir pkg-node --release",
|
|
41
|
+
"build:web": "wasm-pack build --target web --out-dir pkg-web --release",
|
|
42
|
+
"build:dev": "npm run build:node:dev && npm run build:web:dev",
|
|
43
|
+
"build:node:dev": "wasm-pack build --target nodejs --out-dir pkg-node --dev",
|
|
44
|
+
"build:web:dev": "wasm-pack build --target web --out-dir pkg-web --dev",
|
|
45
|
+
"clean": "rm -rf pkg-node pkg-web target",
|
|
46
|
+
"verify": "./verify-build.sh",
|
|
47
|
+
"prepublishOnly": "npm run build && npm run verify"
|
|
48
|
+
},
|
|
49
|
+
"keywords": [
|
|
50
|
+
"excel",
|
|
51
|
+
"xlsx",
|
|
52
|
+
"xls",
|
|
53
|
+
"calamine",
|
|
54
|
+
"rust",
|
|
55
|
+
"wasm",
|
|
56
|
+
"webassembly",
|
|
57
|
+
"parquet",
|
|
58
|
+
"spreadsheet",
|
|
59
|
+
"data-processing"
|
|
60
|
+
],
|
|
61
|
+
"author": "",
|
|
62
|
+
"license": "MIT",
|
|
63
|
+
"repository": {
|
|
64
|
+
"type": "git",
|
|
65
|
+
"url": ""
|
|
66
|
+
},
|
|
67
|
+
"bugs": {
|
|
68
|
+
"url": ""
|
|
69
|
+
},
|
|
70
|
+
"homepage": "",
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=16.0.0"
|
|
73
|
+
},
|
|
74
|
+
"sideEffects": false
|
|
75
|
+
}
|