@sergdudko/objectstream 4.0.6 → 4.0.7
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/dist/cjs/classes/Parser.js +2 -2
- package/dist/cjs/classes/Stringifer.js +2 -2
- package/dist/cjs/index.js +6 -6
- package/dist/esm/classes/Parser.js +49 -7
- package/dist/esm/classes/Stringifer.js +25 -1
- package/dist/esm/index.js +2 -2
- package/dist/types/classes/Parser.d.ts +1 -1
- package/dist/types/classes/Stringifer.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Parser = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
const
|
|
5
|
+
const global_js_1 = require("../utils/global.js");
|
|
6
6
|
/**
|
|
7
7
|
* @class Parser
|
|
8
8
|
*
|
|
@@ -156,7 +156,7 @@ class Parser extends stream_1.Transform {
|
|
|
156
156
|
const _buf = Buffer.concat(this.__buffers);
|
|
157
157
|
const _str = _buf.toString("utf8");
|
|
158
158
|
const _object = JSON.parse(_str);
|
|
159
|
-
if ((0,
|
|
159
|
+
if ((0, global_js_1.validator)(_object, false)) {
|
|
160
160
|
this.__clear();
|
|
161
161
|
this.push(_object);
|
|
162
162
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Stringifer = void 0;
|
|
4
4
|
const stream_1 = require("stream");
|
|
5
|
-
const
|
|
5
|
+
const global_js_1 = require("../utils/global.js");
|
|
6
6
|
/**
|
|
7
7
|
* @class Stringifer
|
|
8
8
|
*
|
|
@@ -68,7 +68,7 @@ class Stringifer extends stream_1.Transform {
|
|
|
68
68
|
switch (typeof object) {
|
|
69
69
|
case "object":
|
|
70
70
|
try {
|
|
71
|
-
if ((0,
|
|
71
|
+
if ((0, global_js_1.validator)(object, false) !== true) {
|
|
72
72
|
callback([
|
|
73
73
|
new Error("Validation failed, incoming data type is not pure Object!"),
|
|
74
74
|
]);
|
package/dist/cjs/index.js
CHANGED
|
@@ -10,19 +10,19 @@
|
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.Stringifer = exports.Parser = void 0;
|
|
13
|
-
const
|
|
14
|
-
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return
|
|
15
|
-
const
|
|
16
|
-
Object.defineProperty(exports, "Stringifer", { enumerable: true, get: function () { return
|
|
13
|
+
const Parser_js_1 = require("./classes/Parser.js");
|
|
14
|
+
Object.defineProperty(exports, "Parser", { enumerable: true, get: function () { return Parser_js_1.Parser; } });
|
|
15
|
+
const Stringifer_js_1 = require("./classes/Stringifer.js");
|
|
16
|
+
Object.defineProperty(exports, "Stringifer", { enumerable: true, get: function () { return Stringifer_js_1.Stringifer; } });
|
|
17
17
|
// Default export for CommonJS compatibility
|
|
18
18
|
const objectstream = {
|
|
19
19
|
/**
|
|
20
20
|
* Object to String stream
|
|
21
21
|
*/
|
|
22
|
-
Stringifer:
|
|
22
|
+
Stringifer: Stringifer_js_1.Stringifer,
|
|
23
23
|
/**
|
|
24
24
|
* String to Object stream
|
|
25
25
|
*/
|
|
26
|
-
Parser:
|
|
26
|
+
Parser: Parser_js_1.Parser,
|
|
27
27
|
};
|
|
28
28
|
exports.default = objectstream;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transform } from "stream";
|
|
2
|
-
import { validator } from "../utils/global";
|
|
2
|
+
import { validator } from "../utils/global.js";
|
|
3
3
|
/**
|
|
4
4
|
* @class Parser
|
|
5
5
|
*
|
|
@@ -43,6 +43,54 @@ export class Parser extends Transform {
|
|
|
43
43
|
this.__rightBrace = 0;
|
|
44
44
|
this.__openQuotes = false;
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* separators
|
|
48
|
+
*
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
__separators;
|
|
52
|
+
/**
|
|
53
|
+
* empty buffer
|
|
54
|
+
*
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
static __empty = Buffer.from("");
|
|
58
|
+
/**
|
|
59
|
+
* stream byte counter
|
|
60
|
+
*
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
__bytesRead;
|
|
64
|
+
/**
|
|
65
|
+
* stream encoding
|
|
66
|
+
*
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
__encoding;
|
|
70
|
+
/**
|
|
71
|
+
* stream buffer
|
|
72
|
+
*
|
|
73
|
+
* @private
|
|
74
|
+
*/
|
|
75
|
+
__buffers;
|
|
76
|
+
/**
|
|
77
|
+
* left brace counter
|
|
78
|
+
*
|
|
79
|
+
* @private
|
|
80
|
+
*/
|
|
81
|
+
__leftBrace;
|
|
82
|
+
/**
|
|
83
|
+
* right brace counter
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
*/
|
|
87
|
+
__rightBrace;
|
|
88
|
+
/**
|
|
89
|
+
* open quote flag
|
|
90
|
+
*
|
|
91
|
+
* @private
|
|
92
|
+
*/
|
|
93
|
+
__openQuotes;
|
|
46
94
|
/**
|
|
47
95
|
* clear buffer and reset counters
|
|
48
96
|
*
|
|
@@ -222,9 +270,3 @@ export class Parser extends Transform {
|
|
|
222
270
|
return this;
|
|
223
271
|
}
|
|
224
272
|
}
|
|
225
|
-
/**
|
|
226
|
-
* empty buffer
|
|
227
|
-
*
|
|
228
|
-
* @private
|
|
229
|
-
*/
|
|
230
|
-
Parser.__empty = Buffer.from("");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transform } from "stream";
|
|
2
|
-
import { validator } from "../utils/global";
|
|
2
|
+
import { validator } from "../utils/global.js";
|
|
3
3
|
/**
|
|
4
4
|
* @class Stringifer
|
|
5
5
|
*
|
|
@@ -39,6 +39,30 @@ export class Stringifer extends Transform {
|
|
|
39
39
|
this.__encoding = "utf8";
|
|
40
40
|
this.setDefaultEncoding(this.__encoding);
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* separators
|
|
44
|
+
*
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
__separators;
|
|
48
|
+
/**
|
|
49
|
+
* pass string data to the stream
|
|
50
|
+
*
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
__isString;
|
|
54
|
+
/**
|
|
55
|
+
* stream byte counter
|
|
56
|
+
*
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
__bytesWrite;
|
|
60
|
+
/**
|
|
61
|
+
* stream encoding
|
|
62
|
+
*
|
|
63
|
+
* @private
|
|
64
|
+
*/
|
|
65
|
+
__encoding;
|
|
42
66
|
/**
|
|
43
67
|
* Data event handler
|
|
44
68
|
*
|
package/dist/esm/index.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* @version 2.0.0
|
|
8
8
|
* @requires stream
|
|
9
9
|
*/
|
|
10
|
-
import { Parser } from "./classes/Parser";
|
|
11
|
-
import { Stringifer } from "./classes/Stringifer";
|
|
10
|
+
import { Parser } from "./classes/Parser.js";
|
|
11
|
+
import { Stringifer } from "./classes/Stringifer.js";
|
|
12
12
|
// Named exports
|
|
13
13
|
export { Parser, Stringifer };
|
|
14
14
|
// Default export for CommonJS compatibility
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* @version 2.0.0
|
|
8
8
|
* @requires stream
|
|
9
9
|
*/
|
|
10
|
-
import { Parser } from "./classes/Parser";
|
|
11
|
-
import { Stringifer } from "./classes/Stringifer";
|
|
10
|
+
import { Parser } from "./classes/Parser.js";
|
|
11
|
+
import { Stringifer } from "./classes/Stringifer.js";
|
|
12
12
|
export { Parser, Stringifer };
|
|
13
13
|
declare const objectstream: {
|
|
14
14
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sergdudko/objectstream",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.7",
|
|
4
4
|
"description": "Creates a stream to convert json from string or convert json to string.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"typescript-eslint": "^8.46.1"
|
|
92
92
|
},
|
|
93
93
|
"engines": {
|
|
94
|
-
"node": ">=
|
|
94
|
+
"node": ">=16"
|
|
95
95
|
},
|
|
96
96
|
"directories": {
|
|
97
97
|
"test": "./test/"
|