equipped 4.1.9 → 4.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/lib/structure/baseEntity.d.ts +1 -0
- package/lib/structure/baseEntity.js +11 -7
- package/lib/utils/json.js +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [4.1.11](https://github.com/kevinand11/equipped/compare/v4.1.10...v4.1.11) (2023-04-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* do not convert value in JSON.parse if it is not a string ([e7d735f](https://github.com/kevinand11/equipped/commit/e7d735f0bc3f82210102d5a9d667e2574eab3cea))
|
|
11
|
+
|
|
12
|
+
### [4.1.10](https://github.com/kevinand11/equipped/compare/v4.1.9...v4.1.10) (2023-04-07)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add list to ignore when converting baseEntity to json ([624d134](https://github.com/kevinand11/equipped/commit/624d134f87b3acbec686cde1ad0c02d6b34dc73b))
|
|
18
|
+
|
|
5
19
|
### [4.1.9](https://github.com/kevinand11/equipped/compare/v4.1.8...v4.1.9) (2023-04-04)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -2,19 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseEntity = void 0;
|
|
4
4
|
const utils_1 = require("../utils/utils");
|
|
5
|
+
const deleteKeyFromObject = (obj, keys) => {
|
|
6
|
+
if (obj === undefined || obj === null)
|
|
7
|
+
return;
|
|
8
|
+
if (keys.length === 1)
|
|
9
|
+
return delete obj[keys[0]];
|
|
10
|
+
const key = keys.pop() ?? '';
|
|
11
|
+
return deleteKeyFromObject(obj[key], keys);
|
|
12
|
+
};
|
|
5
13
|
class BaseEntity {
|
|
6
14
|
constructor() {
|
|
15
|
+
this.ignoreInJSON = [];
|
|
7
16
|
this.hash = utils_1.Random.string();
|
|
8
17
|
}
|
|
9
18
|
toJSON() {
|
|
10
19
|
const json = Object.assign({}, this);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.filter((k) => k !== 'constructor')
|
|
14
|
-
.forEach((key) => {
|
|
15
|
-
const value = this[key];
|
|
16
|
-
json[key] = value?.toJSON?.() ?? value;
|
|
17
|
-
});
|
|
20
|
+
this.ignoreInJSON.forEach((k) => deleteKeyFromObject(json, k.split('.').reverse()));
|
|
21
|
+
delete json.ignoreInJSON;
|
|
18
22
|
return json;
|
|
19
23
|
}
|
|
20
24
|
}
|
package/lib/utils/json.js
CHANGED