🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

json-as

Package Overview
Dependencies
Maintainers
1
Versions
192
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.2.2

assembly/DynamicObject.ts

12

assembly/bench.ts

@@ -5,3 +5,3 @@ import 'wasi'

import { JSON } from './json'
import { JSON } from '.'

@@ -11,3 +11,3 @@ import * as asJSON from "assemblyscript-json"

import { unknown } from './unknown'
import { Object } from './Object'
import { DynamicObject } from './DynamicObject'

@@ -24,3 +24,3 @@ // @ts-ignore

const o = new Object()
const o = new DynamicObject()

@@ -92,7 +92,7 @@ o['hello'] = unknown.wrap('world')

bench('AS-JSON Stringify Dynamic Object', () => {
JSON.stringify<Object>(o)
JSON.stringify<DynamicObject>(o)
})
bench('AS-JSON Parse Object', () => {
JSON.parse<Object>('{"hello":"world"}')
JSON.parse<DynamicObject>('{"hello":"world"}')
})

@@ -123,3 +123,3 @@

// Since AS-JSON returns a string, so does assemblyscript-json in this bench.
// Or else, the bench is biased.
// Or else, the bench is biased.
})

@@ -126,0 +126,0 @@

@@ -5,6 +5,6 @@ import { unknown, unknownTypes } from './unknown'

import { JSON, parseDynamicObject, parseUnknown, parseUnknownArray } from './json'
import { JSON, parseDynamicObject, parseUnknown, parseUnknownArray } from '.'
import { Object } from './Object'
import { DynamicObject } from './DynamicObject'
/*
// Not inlining results in an error for some reason

@@ -184,1 +184,11 @@ // @ts-ignore

check<EmptySchema>('Encode/Decode object', emptyObj)
*/
// Unknown
//check<unknown[]>('Encode/Decode unknown[]', ["Welcome to dynamic arrays", ["Very", ["Deep", ["Array"]]], "It also supports nulls"])
//console.log(JSON.stringify(["Welcome to dynamic arrays", 3.14, ["Very", ["Deep", ["Array"]]], true, "It also supports nulls", null]))
//console.log(JSON.stringify(JSON.parse<unknown[]>('["Welcome to dynamic arrays",3.14,["Very",["Deep",["Array"]]],true,"It also supports nulls",null]')))
const foo = new Map()
//console.log(JSON.stringify(parseDynamicObject('{"hello":"world"}')))
{
"name": "json-as",
"version": "0.2.1",
"version": "0.2.2",
"description": "JSON encoder/decoder for AssemblyScript",
"types": "assembly/json.ts",
"ascMain": "assembly/json.ts",
"types": "assembly/index.ts",
"ascMain": "assembly/index.ts",
"author": "JairusSW",

@@ -34,15 +34,13 @@ "license": "MIT",

"asbuild": "^0.2.0",
"assemblyscript": "^0.19.10",
"assemblyscript": "^0.19.18",
"assemblyscript-json": "^1.1.0",
"jest": "^27.0.6",
"kati": "^0.6.1",
"jest": "^27.3.1",
"kati": "^0.6.2",
"lerna": "^4.0.0",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.4",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
"ts-jest": "^27.0.7",
"ts-node": "^10.4.0",
"typescript": "^4.4.4"
},
"dependencies": {
"@assemblyscript/loader": "^0.19.17"
},
"dependencies": {},
"repository": {

@@ -62,2 +60,2 @@ "type": "git",

"homepage": "https://github.com/aspkg/as-json#readme"
}
}

@@ -6,3 +6,3 @@ "use strict";

function getTypeName(type) {
let _type = utils_1.getName(type);
let _type = (0, utils_1.getName)(type);
const OR_NULL = /\|.*null/;

@@ -33,5 +33,5 @@ if (type.isNullable && !OR_NULL.test(_type)) {

super.visitElementAccessExpression(node);
if (utils_1.toString(node.expression) === 'o') {
if ((0, utils_1.toString)(node.expression) === 'o') {
// Should be like if (node.expression.type.text === "Object") {
const replacer = visitor_as_1.SimpleParser.parseExpression(`u32(changetype<usize>(${utils_1.toString(node.elementExpression)}))`);
const replacer = visitor_as_1.SimpleParser.parseExpression(`u32(changetype<usize>(${(0, utils_1.toString)(node.elementExpression)}))`);
node.elementExpression = replacer;

@@ -54,3 +54,3 @@ this.sources.push(replacer.range.source);

// @ts-ignore
replacement = visitor_as_1.SimpleParser.parseExpression(`unknown.wrap(${utils_1.toString(expr)})`);
replacement = visitor_as_1.SimpleParser.parseExpression(`unknown.wrap(${(0, utils_1.toString)(expr)})`);
node.elementExpressions[i] = replacement;

@@ -72,3 +72,3 @@ this.sources.push(replacement.range.source);

// @ts-ignore
replacement = visitor_as_1.SimpleParser.parseExpression(`unknown.wrap(${utils_1.toString(expr)})`);
replacement = visitor_as_1.SimpleParser.parseExpression(`unknown.wrap(${(0, utils_1.toString)(expr)})`);
exprs[i] = replacement;

@@ -80,3 +80,3 @@ this.sources.push(replacement.range.source);

super.visitFieldDeclaration(node);
const name = utils_1.toString(node.name);
const name = (0, utils_1.toString)(node.name);
if (!node.type) {

@@ -104,3 +104,3 @@ throw new Error(`Field ${name} is missing a type declaration`);

this.currentClass = node;
const name = utils_1.getName(node);
const name = (0, utils_1.getName)(node);
this.encodeStmts.delete(name);

@@ -155,6 +155,6 @@ this.decodeCode.delete(name);

const firstKind = node.elementExpressions[0]?.kind;
const isBoolean = (utils_1.toString(node.elementExpressions[0]) === 'true' || utils_1.toString(node.elementExpressions[0]) === 'false');
const isBoolean = ((0, utils_1.toString)(node.elementExpressions[0]) === 'true' || (0, utils_1.toString)(node.elementExpressions[0]) === 'false');
for (const chunk of node.elementExpressions) {
if (isBoolean) {
if (utils_1.toString(chunk) !== 'true' || utils_1.toString(chunk) !== 'false')
if ((0, utils_1.toString)(chunk) !== 'true' || (0, utils_1.toString)(chunk) !== 'false')
true;

@@ -161,0 +161,0 @@ }