json-as 0.4.7 → 0.4.9

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.
@@ -1,24 +1,24 @@
1
- {
2
- "targets": {
3
- "coverage": {
4
- "lib": ["./node_modules/@as-covers/assembly/index.ts"],
5
- "transform": ["@as-covers/transform", "@as-pect/transform"]
6
- },
7
- "noCoverage": {
8
- "transform": ["@as-pect/transform"]
9
- }
10
- },
11
- "options": {
12
- "exportMemory": true,
13
- "outFile": "output.wasm",
14
- "textFile": "output.wat",
15
- "bindings": "raw",
16
- "exportStart": "_start",
17
- "exportRuntime": true,
18
- "use": ["RTRACE=1"],
19
- "debug": true,
20
- "exportTable": true
21
- },
22
- "extends": "./asconfig.json",
23
- "entries": ["./@as-pect/assembly/assembly/index.ts"]
1
+ {
2
+ "targets": {
3
+ "coverage": {
4
+ "lib": ["@as-covers/assembly/index.ts"],
5
+ "transform": ["@as-covers/transform", "@as-pect/transform"]
6
+ },
7
+ "noCoverage": {
8
+ "transform": ["@as-pect/transform"]
9
+ }
10
+ },
11
+ "options": {
12
+ "exportMemory": true,
13
+ "outFile": "output.wasm",
14
+ "textFile": "output.wat",
15
+ "bindings": "raw",
16
+ "exportStart": "_start",
17
+ "exportRuntime": true,
18
+ "use": ["RTRACE=1"],
19
+ "debug": true,
20
+ "exportTable": true
21
+ },
22
+ "extends": "./asconfig.json",
23
+ "entries": ["./node_modules/@as-pect/assembly/assembly/index.ts"]
24
24
  }
package/as-pect.config.js CHANGED
@@ -2,7 +2,7 @@ export default {
2
2
  /**
3
3
  * A set of globs passed to the glob package that qualify typescript files for testing.
4
4
  */
5
- entries: ["assembly/__tests__/**/*.spec.ts"],
5
+ entries: ["assembly/__tests__/*.spec.ts"],
6
6
  /**
7
7
  * A set of globs passed to the glob package that quality files to be added to each test.
8
8
  */
package/asconfig.json CHANGED
@@ -10,7 +10,7 @@
10
10
  }
11
11
  },
12
12
  "options": {
13
- "transform": "./transform",
13
+ "transform": ["./transform"],
14
14
  "bindings": "esm"
15
15
  }
16
16
  }
@@ -1,4 +1,5 @@
1
1
  import { JSON } from "..";
2
+ import { rainbow } from "as-rainbow/assembly"
2
3
 
3
4
  @json
4
5
  class Vec2 {
@@ -11,7 +12,39 @@ const vec: Vec2 = blackbox<Vec2>({
11
12
  y: 0.0,
12
13
  });
13
14
 
14
- /*
15
+ //console.log(rainbow.bgBlue("Running benchmark for as-json"));
16
+
17
+ bench("Stringify Object (Vec2)", () => {
18
+ blackbox(JSON.stringify(vec));
19
+ });
20
+
21
+ bench("Parse Object (Vec2)", () => {
22
+ blackbox(JSON.parse<Vec2>(blackbox('{"x":0.0,"y":0.0}')));
23
+ });
24
+
25
+ bench("Stringify Array", () => {
26
+ blackbox(JSON.stringify(blackbox([1, 2, 3, 4, 5])));
27
+ });
28
+
29
+ bench("Parse Array", () => {
30
+ blackbox(JSON.parse<i32[]>(blackbox("[1,2,3,4]")));
31
+ });
32
+
33
+ bench("Stringify Nested Array", () => {
34
+ blackbox(
35
+ JSON.stringify<string[][]>(
36
+ blackbox([
37
+ ["a", "b", "c"],
38
+ ["d", "e", "f"],
39
+ ])
40
+ )
41
+ );
42
+ });
43
+
44
+ bench("Parse Nested Array", () => {
45
+ blackbox(JSON.parse<string[][]>(blackbox('[["a","b","c"],["d","e","f"]]')));
46
+ });
47
+
15
48
  bench("Stringify String", () => {
16
49
  blackbox(JSON.stringify(blackbox("Hello")));
17
50
  });
@@ -42,34 +75,4 @@ bench("Stringify Float", () => {
42
75
 
43
76
  bench("Parse Float", () => {
44
77
  blackbox(JSON.parse<f32>(blackbox("3.14")));
45
- });
46
-
47
- bench("Stringify Object (Vec2)", () => {
48
- blackbox(JSON.stringify(vec));
49
- });
50
- */
51
- bench("Parse Object (Vec2)", () => {
52
- const obj = JSON.parse<Vec2>(blackbox('{"x":0.0,"y":0.0}'));
53
- });
54
-
55
- bench("Stringify Array", () => {
56
- blackbox(JSON.stringify(blackbox([1, 2, 3, 4, 5])));
57
- });
58
-
59
- bench("Parse Array", () => {
60
- blackbox(JSON.parse<i32[]>(blackbox("[1,2,3,4]")));
61
- });
62
-
63
- bench("Stringify Nested Array", () => {
64
- blackbox(
65
- JSON.stringify<string[][]>(
66
- blackbox([
67
- ["a", "b", "c"],
68
- ["d", "e", "f"],
69
- ])
70
- )
71
- );
72
- });
73
- bench("Parse Nested Array", () => {
74
- blackbox(JSON.parse<string[][]>(blackbox('[["a","b","c"],["d","e","f"]]')));
75
- });
78
+ });
@@ -2,8 +2,9 @@ import { JSON } from ".."
2
2
  function canSerde<T>(data: T): void {
3
3
  const serialized = JSON.stringify<T>(data);
4
4
  const deserialized = JSON.stringify<T>(JSON.parse<T>(serialized));
5
- expect(serialized).toStrictEqual(deserialized)
5
+ expect(serialized).toBe(deserialized);
6
6
  }
7
+
7
8
  describe("Ser/de Numbers", () => {
8
9
  it("should ser/de integers", () => {
9
10
  canSerde<i32>(0)
@@ -62,7 +63,7 @@ describe("Ser/de Array", () => {
62
63
  })
63
64
 
64
65
  it("should ser/de string arrays", () => {
65
- canSerde<string[]>(["abcdefg", "st\"ring\" w\"\"ith quotes\"", "string \t\r\\\"with ran\tdom spa\nces and \nnewlines\n\n\n", "string with colon : comma , brace [ ] bracket { } and quote \" and other quote \\\""])
66
+ canSerde<string[]>(["abcdefg", "st\"ring\" w\"\"ith quotes\"", "string \t\r\"with ran\tdom spa\nces and \nnewlines\n\n\n", "string with colon : comma , brace [ ] bracket { } and quote \" and other quote \""])
66
67
  });
67
68
 
68
69
  it("should ser/de nested integer arrays", () => {