Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
ab3ae7ec90 | |||
b2bb918ee4 | |||
606ff73f58 | |||
7ea17c792d | |||
4478b7588a | |||
9bac6e5809 |
4
.snyk
4
.snyk
@ -1,4 +0,0 @@
|
|||||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
|
||||||
version: v1.13.3
|
|
||||||
ignore: {}
|
|
||||||
patch: {}
|
|
10615
package-lock.json
generated
10615
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartjson",
|
"name": "@pushrocks/smartjson",
|
||||||
"version": "5.0.0",
|
"version": "5.0.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "typed json handlers",
|
"description": "typed json handlers",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -21,17 +21,17 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartjson#README",
|
"homepage": "https://gitlab.com/pushrocks/smartjson#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.63",
|
"@gitzone/tsbuild": "^2.1.65",
|
||||||
"@gitzone/tsrun": "^1.2.35",
|
"@gitzone/tsrun": "^1.2.37",
|
||||||
"@gitzone/tstest": "^1.0.71",
|
"@gitzone/tstest": "^1.0.73",
|
||||||
"@pushrocks/tapbundle": "^5.0.3",
|
"@pushrocks/tapbundle": "^5.0.4",
|
||||||
"@types/node": "^17.0.41",
|
"@types/node": "^18.7.17"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@pushrocks/smartstring": "^4.0.5",
|
||||||
"@types/buffer-json": "^2.0.1",
|
"@types/buffer-json": "^2.0.1",
|
||||||
"@types/fast-json-stable-stringify": "^2.1.0",
|
"@types/fast-json-stable-stringify": "^2.1.0",
|
||||||
|
"@types/lodash.clonedeep": "^4.5.7",
|
||||||
"buffer-json": "^2.0.0",
|
"buffer-json": "^2.0.0",
|
||||||
"fast-json-stable-stringify": "^2.1.0",
|
"fast-json-stable-stringify": "^2.1.0",
|
||||||
"lodash.clonedeep": "^4.5.0"
|
"lodash.clonedeep": "^4.5.0"
|
||||||
|
4321
pnpm-lock.yaml
generated
Normal file
4321
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -40,4 +40,23 @@ tap.test('should products stable jsons', async () => {
|
|||||||
console.log(jsonString);
|
console.log(jsonString);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should work with base64', async() => {
|
||||||
|
const someObject = {
|
||||||
|
hi: 'there',
|
||||||
|
thisIs: 'awesome',
|
||||||
|
};
|
||||||
|
|
||||||
|
const base64Json = smartjson.stringifyBase64(someObject);
|
||||||
|
console.log(base64Json);
|
||||||
|
const decodedObject = smartjson.parseBase64(base64Json);
|
||||||
|
expect(decodedObject).toEqual(someObject);
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('stringify should handle plain string', async () => {
|
||||||
|
const stringifiedString = smartjson.stringify('hello');
|
||||||
|
console.log(stringifiedString);
|
||||||
|
expect(stringifiedString).toEqual('"hello"')
|
||||||
|
expect(smartjson.parse(stringifiedString)).toEqual('hello');
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartjson',
|
name: '@pushrocks/smartjson',
|
||||||
version: '5.0.0',
|
version: '5.0.3',
|
||||||
description: 'typed json handlers'
|
description: 'typed json handlers'
|
||||||
}
|
}
|
||||||
|
12
ts/index.ts
12
ts/index.ts
@ -21,6 +21,18 @@ export const stringify = (
|
|||||||
return returnJson;
|
return returnJson;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const stringifyBase64 = (...args: Parameters<typeof stringify>): string => {
|
||||||
|
const stringifiedResult = stringify(...args);
|
||||||
|
return plugins.smartstring.base64.encodeUri(stringifiedResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const parseBase64 = (base64JsonStringArg: string) => {
|
||||||
|
const simpleStringified = plugins.smartstring.base64.decode(base64JsonStringArg);
|
||||||
|
return parse(simpleStringified);
|
||||||
|
}
|
||||||
|
|
||||||
|
parse
|
||||||
|
|
||||||
export class Smartjson {
|
export class Smartjson {
|
||||||
/**
|
/**
|
||||||
* enfolds data from an object
|
* enfolds data from an object
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
// @pushrocks scope
|
||||||
|
import * as smartstring from '@pushrocks/smartstring';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartstring
|
||||||
|
}
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import lodashCloneDeep from 'lodash.clonedeep';
|
import lodashCloneDeep from 'lodash.clonedeep';
|
||||||
import stableJson2 from 'fast-json-stable-stringify';
|
import stableJson2 from 'fast-json-stable-stringify';
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"useDefineForClassFields": false,
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "ES2022",
|
||||||
"moduleResolution": "nodenext"
|
"moduleResolution": "nodenext",
|
||||||
|
"esModuleInterop": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
Reference in New Issue
Block a user