Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
25f80b6b59 | |||
176ac34504 | |||
2707542234 | |||
ee025d094c | |||
9bc1c4bf93 | |||
5176a34575 | |||
fe9f9299fc | |||
62cf2fd262 | |||
65e581d48b | |||
4ff97294bb | |||
2d5bd6a2f0 |
@ -1,5 +1,7 @@
|
|||||||
# gitzone ci_default
|
# gitzone ci_default
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
variables:
|
||||||
|
GIT_STRATEGY: clone
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -38,13 +40,25 @@ snyk:
|
|||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
|
||||||
testLTS:
|
testStable:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -86,7 +100,9 @@ trigger:
|
|||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:18-dind
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
@ -48,6 +48,6 @@ foldedObject = myAwesomeInstance.foldToObject(); // will return {anotherValueToS
|
|||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
[](https://maintainedby.lossless.com)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
|
10467
package-lock.json
generated
10467
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartjson",
|
"name": "@pushrocks/smartjson",
|
||||||
"version": "3.0.6",
|
"version": "3.0.12",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "typed json handlers",
|
"description": "typed json handlers",
|
||||||
"main": "dist/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild)"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -20,17 +20,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartjson#README",
|
"homepage": "https://gitlab.com/pushrocks/smartjson#README",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.12",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.52",
|
||||||
"@pushrocks/tapbundle": "^3.0.11",
|
"@pushrocks/tapbundle": "^3.2.9",
|
||||||
"@types/node": "^12.7.1",
|
"@types/node": "^14.11.2",
|
||||||
"tslint": "^5.18.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/buffer-json": "^2.0.0",
|
||||||
"@types/fast-json-stable-stringify": "^2.0.0",
|
"@types/fast-json-stable-stringify": "^2.0.0",
|
||||||
"fast-json-stable-stringify": "^2.0.0",
|
"buffer-json": "^2.0.0",
|
||||||
|
"fast-json-stable-stringify": "^2.1.0",
|
||||||
"lodash.clonedeep": "^4.5.0"
|
"lodash.clonedeep": "^4.5.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
@ -38,6 +40,7 @@
|
|||||||
"ts_web/*",
|
"ts_web/*",
|
||||||
"dist/*",
|
"dist/*",
|
||||||
"dist_web/*",
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
"assets/*",
|
"assets/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
|
@ -26,8 +26,8 @@ tap.test('should create a folded object', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should enfold from object', async () => {
|
tap.test('should enfold from object', async () => {
|
||||||
mySomeClass.enfoldFromObject({ thisis: 'test2' });
|
const mySomeClass2 = SomeClass.enfoldFromObject({ thisis: 'test2' });
|
||||||
expect(mySomeClass)
|
expect(mySomeClass2)
|
||||||
.property('thisis')
|
.property('thisis')
|
||||||
.to.equal('test2');
|
.to.equal('test2');
|
||||||
});
|
});
|
||||||
|
35
ts/index.ts
35
ts/index.ts
@ -4,11 +4,29 @@ export class Smartjson {
|
|||||||
// ======
|
// ======
|
||||||
// STATIC
|
// STATIC
|
||||||
// ======
|
// ======
|
||||||
public static parse = JSON.parse;
|
/**
|
||||||
|
* allows you to parse a json
|
||||||
|
*/
|
||||||
|
public static parse = plugins.bufferJson.parse;
|
||||||
|
|
||||||
public static stringify = (objArg: any, optionsArg: plugins.stableJson.Options) => {
|
public static stringify = (objArg: any, optionsArg: plugins.IStableJsonTypes['Options']) => {
|
||||||
|
const bufferedJson = plugins.bufferJson.stringify(objArg);
|
||||||
|
objArg = JSON.parse(bufferedJson);
|
||||||
return plugins.stableJson(objArg, optionsArg);
|
return plugins.stableJson(objArg, optionsArg);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
// ========
|
// ========
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
@ -26,17 +44,6 @@ export class Smartjson {
|
|||||||
}
|
}
|
||||||
return newFoldedObject;
|
return newFoldedObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* enfolds data from an object
|
|
||||||
*/
|
|
||||||
public enfoldFromObject(objectArg) {
|
|
||||||
for (const keyName in objectArg) {
|
|
||||||
if (this.saveableProperties.indexOf(keyName) !== -1) {
|
|
||||||
this[keyName] = objectArg[keyName];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,4 +1,20 @@
|
|||||||
|
// third party scope
|
||||||
import lodashCloneDeep from 'lodash.clonedeep';
|
import lodashCloneDeep from 'lodash.clonedeep';
|
||||||
import stableJson from 'fast-json-stable-stringify';
|
import stableJson2 from 'fast-json-stable-stringify';
|
||||||
|
import bufferJson from 'buffer-json';
|
||||||
|
|
||||||
export { lodashCloneDeep, stableJson };
|
const stableJson = stableJson2 as any;
|
||||||
|
|
||||||
|
export { bufferJson, lodashCloneDeep, stableJson };
|
||||||
|
|
||||||
|
export interface IStableJsonTypes {
|
||||||
|
Comparator: (a: IStableJsonTypes['CompareDescriptor'], b: IStableJsonTypes['CompareDescriptor']) => number;
|
||||||
|
CompareDescriptor: {
|
||||||
|
key: string;
|
||||||
|
value: any;
|
||||||
|
};
|
||||||
|
Options: {
|
||||||
|
cmp?: (a: IStableJsonTypes['CompareDescriptor'], b: IStableJsonTypes['CompareDescriptor']) => number;
|
||||||
|
cycles?: boolean;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user