fix(core): update

This commit is contained in:
Philipp Kunz 2022-06-09 19:54:43 +02:00
parent 9686caff18
commit 9d7e2e03d9
9 changed files with 8345 additions and 8907 deletions

View File

@ -12,6 +12,9 @@ stages:
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
# ====================
# security stage
# ====================
@ -36,6 +39,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
@ -96,10 +100,9 @@ codequality:
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
@ -119,11 +122,10 @@ trigger:
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci node install stable
- npmci npm prepare
- npmci npm install
- npmci command tsdoc
- npmci command npm run buildDocs
tags:
- lossless
- docker

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

@ -8,7 +8,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartjson",
"shortDescription": "typed json handlers",
"description": "typed json handlers",
"npmPackagename": "@pushrocks/smartjson",
"license": "MIT"
}

17130
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,8 @@
"typings": "dist_ts/index.d.ts",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)"
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
@ -20,17 +21,17 @@
},
"homepage": "https://gitlab.com/pushrocks/smartjson#README",
"devDependencies": {
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.10",
"@types/node": "^14.14.22",
"@gitzone/tsbuild": "^2.1.63",
"@gitzone/tsrun": "^1.2.35",
"@gitzone/tstest": "^1.0.71",
"@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^17.0.41",
"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",
"@types/buffer-json": "^2.0.1",
"@types/fast-json-stable-stringify": "^2.1.0",
"buffer-json": "^2.0.0",
"fast-json-stable-stringify": "^2.1.0",
"lodash.clonedeep": "^4.5.0"
@ -49,5 +50,6 @@
],
"browserslist": [
"last 1 chrome versions"
]
}
],
"type": "module"
}

View File

@ -1,9 +1,9 @@
import { tap, expect } from '@pushrocks/tapbundle';
import { Smartjson, foldDec } from '../ts/index';
import * as smartjson from '../ts/index.js';
class SomeClass extends Smartjson {
@foldDec() thisis: string = 'test';
class SomeClass extends smartjson.Smartjson {
@smartjson.foldDec() thisis: string = 'test';
constructor() {
super();
console.log(this.saveableProperties);
@ -14,18 +14,30 @@ let mySomeClass: SomeClass;
tap.test('should create a Foldable extended instance', async () => {
mySomeClass = new SomeClass();
expect(mySomeClass).to.be.instanceof(SomeClass);
expect(mySomeClass).to.be.instanceof(Smartjson);
expect(mySomeClass).toBeInstanceOf(SomeClass);
expect(mySomeClass).toBeInstanceOf(smartjson.Smartjson);
});
tap.test('should create a folded object', async () => {
let foldedObject = mySomeClass.foldToObject();
expect(foldedObject).property('thisis').to.equal('test');
expect(foldedObject).property('thisis').toEqual('test');
});
tap.test('should enfold from object', async () => {
const mySomeClass2 = SomeClass.enfoldFromObject({ thisis: 'test2' });
expect(mySomeClass2).property('thisis').to.equal('test2');
expect(mySomeClass2).property('thisis').toEqual('test2');
});
tap.test('should products stable jsons', async () => {
const jsonString = smartjson.stringify({
a: 1,
f: 6,
b: 3,
c: 3,
e: 5,
d: 4,
});
console.log(jsonString);
});
tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartjson',
version: '4.0.7',
description: 'typed json handlers'
}

View File

@ -1,4 +1,4 @@
import * as plugins from './smartjson.plugins';
import * as plugins from './smartjson.plugins.js';
/**
* allows you to parse a json
@ -10,10 +10,15 @@ export const parse = plugins.bufferJson.parse;
* @param objArg
* @param optionsArg
*/
export const stringify = (objArg: any, optionsArg: plugins.IStableJsonTypes['Options'] = {}): string => {
export const stringify = (
objArg: any,
simpleOrderArray?: string[],
optionsArg: plugins.IStableJsonTypes['Options'] = {}
): string => {
const bufferedJson = plugins.bufferJson.stringify(objArg);
objArg = JSON.parse(bufferedJson);
return plugins.stableJson(objArg, optionsArg);
let returnJson = plugins.stableJson(objArg, optionsArg);
return returnJson;
};
export class Smartjson {
@ -69,7 +74,7 @@ export class Smartjson {
*/
public foldToJson() {
const foldedObject = this.foldToObject();
return stringify(foldedObject, {});
return stringify(foldedObject);
}
}
@ -89,4 +94,4 @@ export const deepEqualObjects = (object1: any, object2: any): boolean => {
const object1String = stringify(object1);
const object2String = stringify(object2);
return object1String === object2String;
}
};

View File

@ -1,8 +1,9 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"esModuleInterop": true,
"target": "es2017",
"module": "commonjs"
}
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext"
}
}