Skip to content

Commit

Permalink
release: v0.8.2
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Apr 17, 2024
1 parent 4915854 commit a563bfe
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 61 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.8.2 - Properties starting with `static` or `private` would be ignored
70 changes: 15 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<h1>JSON</h1>
<h3 align="center">
<pre>
█████╗ ███████╗ ██╗███████╗ ██████╗ ███╗ ██╗
██╔══██╗██╔════╝ ██║██╔════╝██╔═══██╗████╗ ██║
███████║███████╗█████╗ ██║███████╗██║ ██║██╔██╗ ██║
██╔══██║╚════██║╚════╝██ ██║╚════██║██║ ██║██║╚██╗██║
██║ ██║███████║ ╚█████╔╝███████║╚██████╔╝██║ ╚████║
╚═╝ ╚═╝╚══════╝ ╚════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝

v0.8.2
</pre>
</h3>

## Installation

Expand Down Expand Up @@ -31,9 +42,9 @@ import { JSON } from "json-as/assembly";
// @json or @serializable work here
@json
class Vec3 {
x!: f32;
y!: f32;
z!: f32;
x: f32 = 0.0;
y: f32 = 0.0;
z: f32 = 0.0;
}

@json
Expand Down Expand Up @@ -68,57 +79,6 @@ const parsed = JSON.parse<Player>(stringified);
```

If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
## Performance

Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/master/bench)

Below are benchmark results comparing JavaScript, WAVM (WebAssembly Virtual Machine), and Wasmtime environments.

JavaScript Results

NodeJS v20.5.1 - TinyBench v2.5.0 (V8)
```
┌───────────────────────────┬───────────────┐
│ Task Name │ ops / sec │
├───────────────────────────┼───────────────┤
│ 'Stringify Object (Vec3)' │ '1,191,221' │
│ 'Parse Object (Vec3)' │ '897,759' │
│ 'Stringify Number Array' │ '1,552,255' │
│ 'Parse Number Array' │ '1,225,325' │
│ 'Stringify String' │ '1,761,011' │
│ 'Parse String' │ '80,845' │
└───────────────────────────┴───────────────┘
```

AssemblyScript Results

WAVM v0.0.0-prerelease - as-bench v0.0.0-alpha (LLVM)
```
┌───────────────────────────┬───────────────┐
│ Task Name │ ops / sec │
├───────────────────────────┼───────────────┤
│ 'Stringify Object (Vec3)' │ '6,270,322' │
│ 'Parse Object (Vec3)' │ '8,000,195' |
│ 'Stringify Number Array' │ '6,664,937' │
│ 'Parse Number Array' │ '6,557,357' │
│ 'Stringify String' │ '6,946,947' │
│ 'Parse String' │ '10,952,502' │
└───────────────────────────┴───────────────┘
```

Wasmtime v11.0.1 - as-bench v0.0.0-alpha (Cranelift)
```
┌───────────────────────────┬───────────────┐
│ Task Name │ ops / sec │
├───────────────────────────┼───────────────┤
│ 'Stringify Object (Vec3)' │ '2,038,684' │
│ 'Parse Object (Vec3)' │ '4,623,337' |
│ 'Stringify Number Array' │ '2,500,947' │
│ 'Parse Number Array' │ '2,959,180' │
│ 'Stringify String' │ '3,236,896' │
│ 'Parse String' │ '5,634,594' │
└───────────────────────────┴───────────────┘
```

## Issues

Expand Down
6 changes: 4 additions & 2 deletions assembly/test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { JSON } from "./src/json";
@json
class Person {
private prng: i32 = 23;
staticprng: i32 = 23;
public country: string = '';

constructor(id: u32) {
this.prng = 321;
this.staticprng = 321;
const seed = id.toString();
this.country = this.getCountry();
}
Expand All @@ -17,5 +17,7 @@ class Person {
}

const person = new Person(1);
person.staticprng = 32
let result = JSON.stringify<Person>(person);
console.log(JSON.stringify(JSON.parse<Person>(result)));
console.log(result);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "json-as",
"version": "0.8.1",
"version": "0.8.2",
"description": "JSON encoder/decoder for AssemblyScript",
"types": "assembly/index.ts",
"author": "Jairus Tanaka",
Expand Down
2 changes: 1 addition & 1 deletion transform/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class AsJSONTransform extends BaseVisitor {
const member = mem;
const lineText = toString(member);
//console.log("Member: " + lineText)
if (!lineText.startsWith("private") && !lineText.startsWith("static")) {
if (!lineText.startsWith("private ") && !lineText.startsWith("static ")) {
// @ts-ignore
let type = toString(member.type);
const name = member.name.text;
Expand Down
2 changes: 1 addition & 1 deletion transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@json-as/transform",
"version": "0.8.1",
"version": "0.8.2",
"description": "JSON encoder/decoder for AssemblyScript",
"main": "./lib/index.js",
"author": "Jairus Tanaka",
Expand Down
2 changes: 1 addition & 1 deletion transform/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class AsJSONTransform extends BaseVisitor {
const lineText = toString(member);
//console.log("Member: " + lineText)

if (!lineText.startsWith("private") && !lineText.startsWith("static")) {
if (!lineText.startsWith("private ") && !lineText.startsWith("static ")) {

// @ts-ignore
let type = toString(member.type);
Expand Down

0 comments on commit a563bfe

Please sign in to comment.