Skip to content

Commit

Permalink
feat: change global allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
PuffMeow committed Aug 9, 2023
1 parent 2e954c6 commit 87d95ae
Show file tree
Hide file tree
Showing 8 changed files with 958 additions and 243 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ crate-type = ["cdylib"]
[dependencies]
indexmap = {version = "2.0.0", features = ["serde"]}
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
mimalloc-rust = {version = "0.2"}
napi = {version = "2.12.2", default-features = false, features = ["napi4"]}
napi-derive = "2.12.2"
regex = "1.9.1"
Expand Down
45 changes: 27 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,37 @@

This is a tool that can help you transform your JSON Schema to TypeScript interface quickly🧲.

This is written by Rust(napi-rs) and only support in Node.js(Support for all platforms except Android).
It's written by Rust(napi-rs) and only support in Node.js(Support for all platforms except Android).

If you want the same feature that can work in Browser or all other platforms, you can see [schema2ts](https://github.com/PuffMeow/schema2ts).

Git repository: [rusty-schema2ts](https://github.com/PuffMeow/rusty-schema2ts). If you like it, please give me a little star♥

## TypeScript vs Rust

You can find bench in

| index | Task Name | ops/sec | Average Time (ns) | Margin | Samples |
| ----- | --------------------- | ------- | ------------------ | ------ | ------- |
| 0 | TypeScript: schema2ts | 2,796 | 357534.31021794415 | ±1.08% | 1399 |
| 1 | Rust: rustySchema2ts | 5,431 | 184122.05448994122 | ±0.29% | 2716 |

## Support matrix

| | node12 | node14 | node16 | node18 |
| ---------------------------- | ------ | ------ | ------ | ------ |
| Windows x64 |||||
| Windows x32 |||||
| Windows arm64 |||||
| macOS x64 |||||
| macOS arm64 (m chips) |||||
| Linux x64 gnu (glibc 2.17) |||||
| Linux x64 musl |||||
| Linux arm gnu (glibc 2.17) |||||
| Linux arm64 gnu (glibc 2.17) |||||
| Linux arm64 musl |||||
| FreeBSD x64 |||||

## Install

npm
Expand All @@ -28,22 +53,6 @@ yarn
yarn add @puffmeow/rusty-schema2ts
```

## Support matrix

| | node12 | node14 | node16 | node18 |
| ---------------------------- | ------ | ------ | ------ | ------ |
| Windows x64 |||||
| Windows x32 |||||
| Windows arm64 |||||
| macOS x64 |||||
| macOS arm64 (m chips) |||||
| Linux x64 gnu (glibc 2.17) |||||
| Linux x64 musl |||||
| Linux arm gnu (glibc 2.17) |||||
| Linux arm64 gnu (glibc 2.17) |||||
| Linux arm64 musl |||||
| FreeBSD x64 |||||

## Quick start

It's really easy to use.
Expand Down Expand Up @@ -191,7 +200,7 @@ export interface IArr3 {
| optional | boolean | × | true | If this is enabled, it will generate the optional interface, default value is true |
| ignoreKeys | string[] | × | [] | If you don't want to generate the type of an attribute in a root object, you can pass in the key name of the corresponding attribute.<br /><br />Like this, ignoreKeys: ["firstName", "lastName"]<br /><br />Schema2ts will ignore the two attributes and doesn't generate the type of them. |
| explain | string | × | | Display some comments at the top of the code |
| parseErrorMessage | string | × | // Parse schema error, please check your schema. | When parsing schema error, this message will be return |
| parseErrorMessage | string | × | // Parse schema error, please check your schema. | When parsing schema error, this message will be return |

## More examples

Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "^2.16.2",
"@types/node": "^20.4.4",
"vite": "^4.4.7",
"vitest": "^0.33.0"
"@puffmeow/schema2ts": "^0.2.0",
"@types/node": "^20.4.9",
"tinybench": "^2.5.0",
"vite": "^4.4.9",
"vitest": "^0.34.1"
},
"engines": {
"node": ">= 10"
Expand All @@ -49,7 +51,8 @@
"test": "vitest run",
"build-test": "npm run build && npm run test",
"universal": "napi universal",
"version": "napi version"
"version": "napi version",
"bench": "node bench/index.js"
},
"packageManager": "[email protected]",
"repository": {
Expand Down
Loading

0 comments on commit 87d95ae

Please sign in to comment.