@mmobeus/luadata 0.1.13 → 0.1.15
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/README.md +51 -0
- package/package.json +8 -7
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @mmobeus/luadata
|
|
2
|
+
|
|
3
|
+
Native Node.js addon for parsing Lua data files and converting to JSON. Powered by Rust via N-API.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
npm install @mmobeus/luadata
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```javascript
|
|
14
|
+
import { convertLuaToJson, convertLuaFileToJson } from "@mmobeus/luadata";
|
|
15
|
+
|
|
16
|
+
// Convert Lua data to a JSON string
|
|
17
|
+
const json = convertLuaToJson('playerName = "Thrall"');
|
|
18
|
+
|
|
19
|
+
// Parse into an object
|
|
20
|
+
const data = JSON.parse(convertLuaToJson(luaString));
|
|
21
|
+
|
|
22
|
+
// Convert a file
|
|
23
|
+
const json = convertLuaFileToJson("config.lua");
|
|
24
|
+
|
|
25
|
+
// With options
|
|
26
|
+
const json = convertLuaToJson(luaString, {
|
|
27
|
+
emptyTable: "array",
|
|
28
|
+
arrayMode: "sparse",
|
|
29
|
+
arrayMaxGap: 10,
|
|
30
|
+
stringTransform: { maxLen: 1024, mode: "truncate" },
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Functions are synchronous and call the native Rust parser directly — no initialization step required. TypeScript type definitions are included.
|
|
35
|
+
|
|
36
|
+
## Options
|
|
37
|
+
|
|
38
|
+
All functions accept an optional options object with four groups:
|
|
39
|
+
|
|
40
|
+
- **Schema** (`schema`, `unknownFields`) — provide a JSON Schema string to guide type decisions, overriding heuristics
|
|
41
|
+
- **String transform** — limit string length during parsing (`truncate`, `empty`, `redact`, `replace`)
|
|
42
|
+
- **Array detection** — control how integer-keyed Lua tables map to JSON arrays (`sparse`, `index-only`, `none`)
|
|
43
|
+
- **Empty tables** — choose how empty Lua tables render in JSON (`null`, `omit`, `array`, `object`)
|
|
44
|
+
|
|
45
|
+
See the [full options documentation](https://github.com/mmobeus/luadata#options) for details and examples.
|
|
46
|
+
|
|
47
|
+
## Links
|
|
48
|
+
|
|
49
|
+
- [Luadata by Example](https://mmobeus.github.io/luadata/docs/) — guided tour with interactive examples
|
|
50
|
+
- [Live Converter](https://mmobeus.github.io/luadata/) — try it in your browser
|
|
51
|
+
- [GitHub](https://github.com/mmobeus/luadata)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mmobeus/luadata",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Parse Lua data files and convert to JSON (native Node.js addon)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"index.js",
|
|
19
|
-
"index.d.ts"
|
|
19
|
+
"index.d.ts",
|
|
20
|
+
"README.md"
|
|
20
21
|
],
|
|
21
22
|
"scripts": {
|
|
22
23
|
"build": "napi build --platform --release",
|
|
@@ -26,11 +27,11 @@
|
|
|
26
27
|
"@napi-rs/cli": "^3.4.0"
|
|
27
28
|
},
|
|
28
29
|
"optionalDependencies": {
|
|
29
|
-
"@mmobeus/luadata-linux-x64-gnu": "0.1.
|
|
30
|
-
"@mmobeus/luadata-linux-arm64-gnu": "0.1.
|
|
31
|
-
"@mmobeus/luadata-darwin-x64": "0.1.
|
|
32
|
-
"@mmobeus/luadata-darwin-arm64": "0.1.
|
|
33
|
-
"@mmobeus/luadata-win32-x64-msvc": "0.1.
|
|
30
|
+
"@mmobeus/luadata-linux-x64-gnu": "0.1.15",
|
|
31
|
+
"@mmobeus/luadata-linux-arm64-gnu": "0.1.15",
|
|
32
|
+
"@mmobeus/luadata-darwin-x64": "0.1.15",
|
|
33
|
+
"@mmobeus/luadata-darwin-arm64": "0.1.15",
|
|
34
|
+
"@mmobeus/luadata-win32-x64-msvc": "0.1.15"
|
|
34
35
|
},
|
|
35
36
|
"license": "MIT",
|
|
36
37
|
"repository": {
|