fix(core): update
This commit is contained in:
parent
4478b7588a
commit
7ea17c792d
5932
package-lock.json
generated
5932
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -21,13 +21,14 @@
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/smartjson#README",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tsbuild": "^2.1.65",
|
||||
"@gitzone/tsrun": "^1.2.37",
|
||||
"@gitzone/tstest": "^1.0.71",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^18.0.0"
|
||||
"@gitzone/tstest": "^1.0.73",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.7.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartstring": "^4.0.5",
|
||||
"@types/buffer-json": "^2.0.1",
|
||||
"@types/fast-json-stable-stringify": "^2.1.0",
|
||||
"@types/lodash.clonedeep": "^4.5.7",
|
||||
|
@ -40,4 +40,16 @@ tap.test('should products stable jsons', async () => {
|
||||
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.start();
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartjson',
|
||||
version: '5.0.1',
|
||||
version: '5.0.2',
|
||||
description: 'typed json handlers'
|
||||
}
|
||||
|
12
ts/index.ts
12
ts/index.ts
@ -21,6 +21,18 @@ export const stringify = (
|
||||
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 {
|
||||
/**
|
||||
* enfolds data from an object
|
||||
|
@ -1,3 +1,10 @@
|
||||
// @pushrocks scope
|
||||
import * as smartstring from '@pushrocks/smartstring';
|
||||
|
||||
export {
|
||||
smartstring
|
||||
}
|
||||
|
||||
// third party scope
|
||||
import lodashCloneDeep from 'lodash.clonedeep';
|
||||
import stableJson2 from 'fast-json-stable-stringify';
|
||||
|
Loading…
Reference in New Issue
Block a user