Socket
Socket
Sign inDemoInstall

@pushrocks/smartjson

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pushrocks/smartjson - npm Package Compare versions

Comparing version 3.0.10 to 4.0.1

dist_ts/index.d.ts

1

npmextra.json

@@ -6,2 +6,3 @@ {

"gitzone": {
"projectType": "npm",
"module": {

@@ -8,0 +9,0 @@ "githost": "gitlab.com",

40

package.json
{
"name": "@pushrocks/smartjson",
"version": "3.0.10",
"version": "4.0.1",
"private": false,
"description": "typed json handlers",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)"
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
},

@@ -23,12 +23,14 @@ "repository": {

"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^12.12.17",
"tslint": "^5.20.1",
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.11.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@types/buffer-json": "^2.0.0",
"@types/fast-json-stable-stringify": "^2.0.0",
"buffer-json": "^2.0.0",
"fast-json-stable-stringify": "^2.1.0",

@@ -38,12 +40,16 @@ "lodash.clonedeep": "^4.5.0"

"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}
import * as plugins from './smartjson.plugins';
/**
* allows you to parse a json
*/
export const parse = plugins.bufferJson.parse;
/**
*
* @param objArg
* @param optionsArg
*/
export const stringify = (objArg: any, optionsArg: plugins.IStableJsonTypes['Options'] = {}) => {
const bufferedJson = plugins.bufferJson.stringify(objArg);
objArg = JSON.parse(bufferedJson);
return plugins.stableJson(objArg, optionsArg);
};
export class Smartjson {
// ======
// STATIC
// ======
public static parse = JSON.parse;
/**
* enfolds data from an object
*/
public static enfoldFromObject(objectArg) {
const newInstance = new this();
for (const keyName in objectArg) {
if (newInstance.saveableProperties.indexOf(keyName) !== -1) {
newInstance[keyName] = objectArg[keyName];
}
}
return newInstance;
}
public static stringify = (objArg: any, optionsArg: plugins.IStableJsonTypes['Options']) => {
return plugins.stableJson(objArg, optionsArg);
/**
* enfold from json
*/
public static enfoldFromJson(jsonArg: string) {
const objectFromJson = parse(jsonArg);
return this.enfoldFromObject(objectFromJson);
}

@@ -31,10 +59,7 @@

/**
* enfolds data from an object
* folds a class into an object
*/
public enfoldFromObject(objectArg) {
for (const keyName in objectArg) {
if (this.saveableProperties.indexOf(keyName) !== -1) {
this[keyName] = objectArg[keyName];
}
}
public foldToJson() {
const foldedObject = this.foldToObject();
return stringify(foldedObject, {});
}

@@ -41,0 +66,0 @@ }

@@ -0,18 +1,26 @@

// third party scope
import lodashCloneDeep from 'lodash.clonedeep';
import stableJson2 from 'fast-json-stable-stringify';
import bufferJson from 'buffer-json';
const stableJson = stableJson2 as any;
export { lodashCloneDeep, stableJson };
export { bufferJson, lodashCloneDeep, stableJson };
export interface IStableJsonTypes {
Comparator: (a: IStableJsonTypes['CompareDescriptor'], b: IStableJsonTypes['CompareDescriptor']) => number;
Comparator: (
a: IStableJsonTypes['CompareDescriptor'],
b: IStableJsonTypes['CompareDescriptor']
) => number;
CompareDescriptor: {
key: string;
value: any;
key: string;
value: any;
};
Options: {
cmp?: (a: IStableJsonTypes['CompareDescriptor'], b: IStableJsonTypes['CompareDescriptor']) => number;
cmp?: (
a: IStableJsonTypes['CompareDescriptor'],
b: IStableJsonTypes['CompareDescriptor']
) => number;
cycles?: boolean;
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc