@pushrocks/smartjson
Advanced tools
Comparing version 3.0.10 to 4.0.1
@@ -6,2 +6,3 @@ { | ||
"gitzone": { | ||
"projectType": "npm", | ||
"module": { | ||
@@ -8,0 +9,0 @@ "githost": "gitlab.com", |
{ | ||
"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; | ||
}; | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11431
258
5
8
2
0
1
+ Added@types/buffer-json@^2.0.0
+ Addedbuffer-json@^2.0.0
+ Added@types/buffer-json@2.0.3(transitive)
+ Addedbuffer-json@2.0.0(transitive)