@chubbyts/chubbyts-decode-encode 1.0.4 → 1.1.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 +1 -1
- package/dist/encoder/index.d.ts +1 -1
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -25,8 +25,8 @@ A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.
|
|
|
25
25
|
|
|
26
26
|
* node: 14
|
|
27
27
|
* [@chubbyts/chubbyts-throwable-to-error][2]: ^1.0.0
|
|
28
|
-
* [fast-xml-parser][3]: ^4.0.
|
|
29
|
-
* [qs][4]: ^6.
|
|
28
|
+
* [fast-xml-parser][3]: ^4.0.10
|
|
29
|
+
* [qs][4]: ^6.11.0
|
|
30
30
|
* [yaml][5]: ^2.1.1
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
@@ -34,7 +34,7 @@ A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.
|
|
|
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.
|
|
37
|
+
npm i @chubbyts/chubbyts-decode-encode@^1.1.1
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Usage
|
|
@@ -48,7 +48,7 @@ import { createDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder';
|
|
|
48
48
|
import { createJsonTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/json-type-decoder';
|
|
49
49
|
|
|
50
50
|
const decoder = createDecoder([createJsonTypeDecoder()]);
|
|
51
|
-
const data = decoder.decode('{"key":"value"}', 'application/json');
|
|
51
|
+
const data = decoder.decode('{"key":"value"}', 'application/json'); // or with 3th argument, for example { user: 'username1' }
|
|
52
52
|
// data: {key: "value"}
|
|
53
53
|
const contentTypes = decoder.contentTypes;
|
|
54
54
|
// contentTypes: ['application/json']
|
|
@@ -88,7 +88,7 @@ const contentType = jsonxTypeDecoder.contentType;
|
|
|
88
88
|
```ts
|
|
89
89
|
import { createUrlEncodedTypeDecoder } from '@chubbyts/chubbyts-decode-encode/dist/decoder/url-encoded-type-decoder';
|
|
90
90
|
|
|
91
|
-
const urlEncodedTypeDecoder = createUrlEncodedTypeDecoder()
|
|
91
|
+
const urlEncodedTypeDecoder = createUrlEncodedTypeDecoder();
|
|
92
92
|
const data = urlEncodedTypeDecoder.decode('key=value');
|
|
93
93
|
// data: {key: "value"}
|
|
94
94
|
const contentType = urlEncodedTypeDecoder.contentType;
|
|
@@ -116,7 +116,7 @@ import { createEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder';
|
|
|
116
116
|
import { createJsonTypeEncoder } from '@chubbyts/chubbyts-encode-encode/dist/encoder/json-type-encoder';
|
|
117
117
|
|
|
118
118
|
const encoder = createEncoder([createJsonTypeEncoder()]);
|
|
119
|
-
const encodedData = encoder.encode({key: "value"}, 'application/json');
|
|
119
|
+
const encodedData = encoder.encode({key: "value"}, 'application/json'); // or with 3th argument, for example { user: 'username1' }
|
|
120
120
|
// encodedData: {"key":"value"}
|
|
121
121
|
const contentTypes = encoder.contentTypes;
|
|
122
122
|
// contentTypes: ['application/json']
|
package/dist/decoder/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type TypeDecoder = {
|
|
|
6
6
|
contentType: string;
|
|
7
7
|
};
|
|
8
8
|
export declare type Decoder = {
|
|
9
|
-
decode: (encodedData: string, contentType: string) => Data;
|
|
9
|
+
decode: (encodedData: string, contentType: string, context?: Record<string, unknown>) => Data;
|
|
10
10
|
contentTypes: Array<string>;
|
|
11
11
|
};
|
|
12
12
|
export declare const createDecoder: (decoderTypes: Array<TypeDecoder>) => Decoder;
|
package/dist/encoder/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare type TypeEncoder = {
|
|
|
6
6
|
contentType: string;
|
|
7
7
|
};
|
|
8
8
|
export declare type Encoder = {
|
|
9
|
-
encode: (data: Data, contentType: string) => string;
|
|
9
|
+
encode: (data: Data, contentType: string, context?: Record<string, unknown>) => string;
|
|
10
10
|
contentTypes: Array<string>;
|
|
11
11
|
};
|
|
12
12
|
export declare const createEncoder: (encoderTypes: Array<TypeEncoder>) => Encoder;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chubbyts/chubbyts-decode-encode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A simple decode/encode solution for json / jsonx / url-encoded / xml / yaml.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chubbyts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"cs": "prettier --check src tests",
|
|
21
21
|
"test": "jest",
|
|
22
22
|
"infection": "stryker run",
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"prepare": "
|
|
23
|
+
"build": "rm -Rf dist && tsc",
|
|
24
|
+
"prepare": "npm run build"
|
|
25
25
|
},
|
|
26
26
|
"jest": {
|
|
27
27
|
"preset": "ts-jest",
|
|
@@ -49,20 +49,20 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@chubbyts/chubbyts-throwable-to-error": "^1.0.0",
|
|
52
|
-
"fast-xml-parser": "^4.0.
|
|
53
|
-
"qs": "^6.
|
|
52
|
+
"fast-xml-parser": "^4.0.10",
|
|
53
|
+
"qs": "^6.11.0",
|
|
54
54
|
"yaml": "^2.1.1"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@stryker-mutator/core": "^6.
|
|
58
|
-
"@stryker-mutator/jest-runner": "^6.
|
|
59
|
-
"@types/jest": "^
|
|
60
|
-
"@types/node": "^14",
|
|
57
|
+
"@stryker-mutator/core": "^6.2.2",
|
|
58
|
+
"@stryker-mutator/jest-runner": "^6.2.2",
|
|
59
|
+
"@types/jest": "^29.0.3",
|
|
60
|
+
"@types/node": "^14.18.29",
|
|
61
61
|
"@types/qs": "^6.9.7",
|
|
62
|
-
"jest": "^
|
|
63
|
-
"prettier": "^2.
|
|
64
|
-
"ts-jest": "^
|
|
65
|
-
"typescript": "^4.
|
|
62
|
+
"jest": "^29.0.3",
|
|
63
|
+
"prettier": "^2.7.1",
|
|
64
|
+
"ts-jest": "^29.0.1",
|
|
65
|
+
"typescript": "^4.8.3"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|