You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

json-as

Package Overview
Dependencies
Maintainers
1
Versions
195
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-as - npm Package Compare versions

Comparing version

to
0.5.58

25

assembly/test.ts

@@ -1,3 +0,3 @@

import { bench, blackbox } from "../../../WebAssembly/benchmark-wasm/assembly/bench";
import { JSON, parseString, parseStringArray, parseStringArrayVirtual, serializeString } from "./src/json";
import { bench, blackbox } from "as-bench/assembly/bench";
import { JSON } from "./src/json";
// @ts-ignore

@@ -48,21 +48,2 @@ @json

console.log("Implemented: " + JSON.stringify(JSON.parse<Player>('{"firstName":"Emmet","lastName":"West","lastActive":[8,27,2022],"age":23,"pos":{"x":3.4,"y":1.2,"z":8.3},"isVerified":true}')));
console.log("Serialized String: " + serializeString('st"ring" w""ith quotes"'));
console.log("Parsed Array: " + JSON.stringify(parseStringArray('["st\\"ring\\" w\\"\\"ith quotes\\""]')));
console.log("Parsed Array: " + JSON.stringify(parseStringArrayVirtual('["st\\"ring\\" w\\"\\"ith quotes\\""]')));
bench("New Stringify String", () => {
blackbox<string>(serializeString(blackbox<string>('st"ring" w""ith quotes"')));
});
bench("New Parse String", () => {
blackbox<string>(parseString(blackbox<string>('"st\\"ring\\" w\\"\\"ith quotes\\""')))
});
bench("Old Parse String Array", () => {
blackbox<string[]>(parseStringArray('["st\\"ring\\" w\\"\\"ith quotes\\""]'));
})
bench("New Parse String Array", () => {
blackbox<string[]>(parseStringArrayVirtual('["st\\"ring\\" w\\"\\"ith quotes\\""]'));
});
/*

@@ -75,3 +56,3 @@ // 9,325,755

// 17,747,531 -> 55,517,015
/*bench("New Parse Object (Vec3)", () => {
bench("New Parse Object (Vec3)", () => {
blackbox<Vec3>(vec.__JSON_Deserialize(blackbox<string>('{"x":0,"y":0,"z":0}')));

@@ -78,0 +59,0 @@ });

2

bench/benchmark.ts

@@ -1,2 +0,2 @@

import { bench, blackbox } from "../../../WebAssembly/benchmark-wasm/assembly/bench";
import { bench, blackbox } from "as-bench/assembly/bench";
import { __atoi_fast } from "../assembly/src/util";

@@ -3,0 +3,0 @@ import { JSON } from "../assembly";

{
"name": "json-as",
"version": "0.5.57",
"version": "0.5.58",
"description": "JSON encoder/decoder for AssemblyScript",

@@ -5,0 +5,0 @@ "types": "assembly/index.ts",

# AS-JSON
![AssemblyScript](https://img.shields.io/badge/AssemblyScript-blue)
![WebAssembly](https://img.shields.io/badge/WebAssemby-purple)
JSON for AssemblyScript focused on performance, low-overhead, and ease-of-use.

@@ -24,2 +21,3 @@

{
// ...
"options": {

@@ -72,8 +70,8 @@ "transform": ["json-as/transform"]

If you use this project in your codebase, consider dropping a [star](https://github.com/JairusSW/as-json). I would really appreciate it!
## Performance
Here are some benchmarks I took with `tinybench` (JavaScript) and `astral` (AssemblyScript).
I took the benchmarks using the stub runtime which doesn't call the Garbage Collector, so you may expect a 10% to 40% decrease from low to high throughput.
Run or view the benchmarks [here](https://github.com/JairusSW/as-json/tree/master/bench)
Tests are run on Ubuntu/WSL2 with a AMD Ryzen 9 CPU
Below are benchmark results comparing JavaScript, WAVM (WebAssembly Virtual Machine), and Wasmtime environments.

@@ -128,2 +126,2 @@ JavaScript Results

Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
Please submit an issue to https://github.com/JairusSW/as-json/issues if you find anything wrong with this library
{
"name": "@json-as/transform",
"version": "0.5.57",
"version": "0.5.58",
"description": "JSON encoder/decoder for AssemblyScript",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.