@chubbyts/chubbyts-decode-encode 1.1.3 → 1.2.1
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/README.md +6 -6
- package/dist/decoder/index.d.ts +2 -1
- package/dist/decoder/index.js +4 -0
- package/dist/decoder/json-type-decoder.d.ts +1 -1
- package/dist/decoder/json-type-decoder.js +1 -3
- package/dist/decoder/jsonx-type-decoder.d.ts +1 -1
- package/dist/decoder/jsonx-type-decoder.js +3 -5
- package/dist/decoder/url-encoded-type-decoder.d.ts +1 -1
- package/dist/decoder/url-encoded-type-decoder.js +1 -1
- package/dist/decoder/yaml-type-decoder.d.ts +1 -1
- package/dist/decoder/yaml-type-decoder.js +2 -4
- package/dist/encoder/index.d.ts +2 -1
- package/dist/encoder/index.js +4 -0
- package/dist/encoder/json-type-encoder.d.ts +1 -1
- package/dist/encoder/jsonx-type-encoder.d.ts +1 -1
- package/dist/encoder/jsonx-type-encoder.js +5 -7
- package/dist/encoder/url-encoded-type-encoder.d.ts +1 -1
- package/dist/encoder/yaml-type-encoder.d.ts +1 -1
- package/package.json +18 -14
package/README.md
CHANGED
|
@@ -23,18 +23,18 @@ A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.
|
|
|
23
23
|
|
|
24
24
|
## Requirements
|
|
25
25
|
|
|
26
|
-
* node:
|
|
27
|
-
* [@chubbyts/chubbyts-throwable-to-error][2]: ^1.
|
|
28
|
-
* [fast-xml-parser][3]: ^4.
|
|
29
|
-
* [qs][4]: ^6.11.
|
|
30
|
-
* [yaml][5]: ^2.
|
|
26
|
+
* node: 16
|
|
27
|
+
* [@chubbyts/chubbyts-throwable-to-error][2]: ^1.1.1
|
|
28
|
+
* [fast-xml-parser][3]: ^4.2.5
|
|
29
|
+
* [qs][4]: ^6.11.2
|
|
30
|
+
* [yaml][5]: ^2.3.1
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
33
|
|
|
34
34
|
Through [NPM](https://www.npmjs.com) as [@chubbyts/chubbyts-decode-encode][1].
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
|
-
npm i @chubbyts/chubbyts-decode-encode@^1.1
|
|
37
|
+
npm i @chubbyts/chubbyts-decode-encode@^1.2.1
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Usage
|
package/dist/decoder/index.d.ts
CHANGED
package/dist/decoder/index.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDecoder = exports.DecodeError = void 0;
|
|
4
4
|
class DecodeError extends Error {
|
|
5
|
+
constructor(message, stack) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.stack = stack;
|
|
8
|
+
}
|
|
5
9
|
}
|
|
6
10
|
exports.DecodeError = DecodeError;
|
|
7
11
|
const createDecoder = (decoderTypes) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeDecoder } from '.';
|
|
1
|
+
import type { TypeDecoder } from '.';
|
|
2
2
|
export declare const createJsonTypeDecoder: () => TypeDecoder;
|
|
@@ -11,9 +11,7 @@ const createJsonTypeDecoder = () => {
|
|
|
11
11
|
}
|
|
12
12
|
catch (e) {
|
|
13
13
|
const error = (0, throwable_to_error_1.throwableToError)(e);
|
|
14
|
-
|
|
15
|
-
decodeError.stack = error.stack;
|
|
16
|
-
throw decodeError;
|
|
14
|
+
throw new _1.DecodeError(error.message, error.stack);
|
|
17
15
|
}
|
|
18
16
|
},
|
|
19
17
|
contentType: 'application/json',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeDecoder } from '.';
|
|
1
|
+
import type { TypeDecoder } from '.';
|
|
2
2
|
export declare const createJsonxTypeDecoder: () => TypeDecoder;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createJsonxTypeDecoder = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
4
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
6
|
-
const jsonx_datatypes_1 = require("../jsonx-datatypes");
|
|
7
5
|
const throwable_to_error_1 = require("@chubbyts/chubbyts-throwable-to-error/dist/throwable-to-error");
|
|
6
|
+
const jsonx_datatypes_1 = require("../jsonx-datatypes");
|
|
7
|
+
const _1 = require(".");
|
|
8
8
|
const decodeHtmlEntities = (string) => string.replace(/&#\d+;/gm, (code) => String.fromCharCode(code.match(/\d+/)[0]));
|
|
9
9
|
const isWithName = (node) => typeof node === 'object' &&
|
|
10
10
|
null !== node &&
|
|
@@ -86,9 +86,7 @@ const createJsonxTypeDecoder = () => {
|
|
|
86
86
|
}
|
|
87
87
|
catch (e) {
|
|
88
88
|
const error = (0, throwable_to_error_1.throwableToError)(e);
|
|
89
|
-
|
|
90
|
-
decodeError.stack = error.stack;
|
|
91
|
-
throw decodeError;
|
|
89
|
+
throw new _1.DecodeError(error.message, error.stack);
|
|
92
90
|
}
|
|
93
91
|
},
|
|
94
92
|
contentType: 'application/jsonx+xml',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeDecoder } from '.';
|
|
1
|
+
import type { TypeDecoder } from '.';
|
|
2
2
|
export declare const createUrlEncodedTypeDecoder: () => TypeDecoder;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createUrlEncodedTypeDecoder = void 0;
|
|
4
|
-
const __1 = require("..");
|
|
5
4
|
const qs_1 = require("qs");
|
|
5
|
+
const __1 = require("..");
|
|
6
6
|
const decodeValue = (value) => {
|
|
7
7
|
if ((0, __1.isObject)(value)) {
|
|
8
8
|
return Object.fromEntries(Object.entries(value).map(([subKey, subValue]) => [subKey, decodeValue(subValue)]));
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeDecoder } from '.';
|
|
1
|
+
import type { TypeDecoder } from '.';
|
|
2
2
|
export declare const createYamlTypeDecoder: () => TypeDecoder;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createYamlTypeDecoder = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
4
|
const yaml_1 = require("yaml");
|
|
6
5
|
const throwable_to_error_1 = require("@chubbyts/chubbyts-throwable-to-error/dist/throwable-to-error");
|
|
6
|
+
const _1 = require(".");
|
|
7
7
|
const createYamlTypeDecoder = () => {
|
|
8
8
|
return {
|
|
9
9
|
decode: (encodedData) => {
|
|
@@ -12,9 +12,7 @@ const createYamlTypeDecoder = () => {
|
|
|
12
12
|
}
|
|
13
13
|
catch (e) {
|
|
14
14
|
const error = (0, throwable_to_error_1.throwableToError)(e);
|
|
15
|
-
|
|
16
|
-
decodeError.stack = error.stack;
|
|
17
|
-
throw decodeError;
|
|
15
|
+
throw new _1.DecodeError(error.message, error.stack);
|
|
18
16
|
}
|
|
19
17
|
},
|
|
20
18
|
contentType: 'application/x-yaml',
|
package/dist/encoder/index.d.ts
CHANGED
package/dist/encoder/index.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createEncoder = exports.EncodeError = void 0;
|
|
4
4
|
class EncodeError extends Error {
|
|
5
|
+
constructor(message, stack) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.stack = stack;
|
|
8
|
+
}
|
|
5
9
|
}
|
|
6
10
|
exports.EncodeError = EncodeError;
|
|
7
11
|
const createEncoder = (encoderTypes) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeEncoder } from '.';
|
|
1
|
+
import type { TypeEncoder } from '.';
|
|
2
2
|
export declare const createJsonTypeEncoder: (prettyPrint?: boolean) => TypeEncoder;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeEncoder } from '.';
|
|
1
|
+
import type { TypeEncoder } from '.';
|
|
2
2
|
export declare const createJsonxTypeEncoder: (prettyPrint?: boolean) => TypeEncoder;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createJsonxTypeEncoder = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const __1 = require("..");
|
|
6
|
-
const jsonx_datatypes_1 = require("../jsonx-datatypes");
|
|
7
4
|
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
8
5
|
const throwable_to_error_1 = require("@chubbyts/chubbyts-throwable-to-error/dist/throwable-to-error");
|
|
9
|
-
const
|
|
6
|
+
const __1 = require("..");
|
|
7
|
+
const jsonx_datatypes_1 = require("../jsonx-datatypes");
|
|
8
|
+
const _1 = require(".");
|
|
9
|
+
const encodeHtmlEntities = (string) => string.replace(/[\u00A0-\u9999<>&]/g, (i) => '&#' + i.charCodeAt(0) + ';');
|
|
10
10
|
const createXmlNode = () => {
|
|
11
11
|
return {
|
|
12
12
|
'?xml': [
|
|
@@ -168,9 +168,7 @@ const createJsonxTypeEncoder = (prettyPrint = false) => {
|
|
|
168
168
|
}
|
|
169
169
|
catch (e) {
|
|
170
170
|
const error = (0, throwable_to_error_1.throwableToError)(e);
|
|
171
|
-
|
|
172
|
-
decodeError.stack = error.stack;
|
|
173
|
-
throw decodeError;
|
|
171
|
+
throw new _1.EncodeError(error.message, error.stack);
|
|
174
172
|
}
|
|
175
173
|
},
|
|
176
174
|
contentType: 'application/jsonx+xml',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeEncoder } from '.';
|
|
1
|
+
import type { TypeEncoder } from '.';
|
|
2
2
|
export declare const createUrlEncodedTypeEncoder: () => TypeEncoder;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TypeEncoder } from '.';
|
|
1
|
+
import type { TypeEncoder } from '.';
|
|
2
2
|
export declare const createYamlTypeEncoder: () => TypeEncoder;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chubbyts/chubbyts-decode-encode",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chubbyts",
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"scripts": {
|
|
19
19
|
"cs-fix": "prettier --write src tests",
|
|
20
20
|
"cs": "prettier --check src tests",
|
|
21
|
+
"lint-fix": "eslint src tests --fix",
|
|
22
|
+
"lint": "eslint src tests",
|
|
21
23
|
"test": "jest",
|
|
22
24
|
"infection": "stryker run",
|
|
23
25
|
"build": "rm -Rf dist && tsc",
|
|
@@ -45,24 +47,26 @@
|
|
|
45
47
|
"dist"
|
|
46
48
|
],
|
|
47
49
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
50
|
+
"node": ">=16"
|
|
49
51
|
},
|
|
50
52
|
"dependencies": {
|
|
51
|
-
"@chubbyts/chubbyts-throwable-to-error": "^1.
|
|
52
|
-
"fast-xml-parser": "^4.
|
|
53
|
-
"qs": "^6.11.
|
|
54
|
-
"yaml": "^2.
|
|
53
|
+
"@chubbyts/chubbyts-throwable-to-error": "^1.1.1",
|
|
54
|
+
"fast-xml-parser": "^4.2.5",
|
|
55
|
+
"qs": "^6.11.2",
|
|
56
|
+
"yaml": "^2.3.1"
|
|
55
57
|
},
|
|
56
58
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
59
|
+
"@chubbyts/chubbyts-eslint": "^1.1.2",
|
|
60
|
+
"@chubbyts/chubbyts-function-mock": "^1.3.6",
|
|
61
|
+
"@stryker-mutator/core": "^7.1.0",
|
|
62
|
+
"@stryker-mutator/jest-runner": "^7.1.0",
|
|
63
|
+
"@types/jest": "^29.5.3",
|
|
64
|
+
"@types/node": "^20.4.1",
|
|
61
65
|
"@types/qs": "^6.9.7",
|
|
62
|
-
"jest": "^29.
|
|
63
|
-
"prettier": "^
|
|
64
|
-
"ts-jest": "^29.
|
|
65
|
-
"typescript": "^
|
|
66
|
+
"jest": "^29.6.1",
|
|
67
|
+
"prettier": "^3.0.0",
|
|
68
|
+
"ts-jest": "^29.1.1",
|
|
69
|
+
"typescript": "^5.1.6"
|
|
66
70
|
},
|
|
67
71
|
"publishConfig": {
|
|
68
72
|
"access": "public"
|