@sergdudko/objectstream 2.0.4 → 3.1.0
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 +2 -27
- package/README.md +4 -1
- package/ignoreUpdatesModules.json +4 -0
- package/lib/classes/Parser.d.ts +102 -0
- package/lib/classes/Parser.js +231 -0
- package/lib/classes/Parser.js.map +1 -0
- package/lib/classes/Stringifer.d.ts +70 -0
- package/lib/classes/Stringifer.js +144 -0
- package/lib/classes/Stringifer.js.map +1 -0
- package/lib/index.d.ts +2 -169
- package/lib/index.js +4 -394
- package/lib/index.js.map +1 -1
- package/lib/utils/global.d.ts +8 -0
- package/lib/utils/global.js +40 -0
- package/lib/utils/global.js.map +1 -0
- package/package.json +22 -14
- package/lib/index.d.ts.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -7,174 +7,8 @@
|
|
|
7
7
|
* @version 2.0.0
|
|
8
8
|
* @requires stream
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
/**
|
|
13
|
-
* @class Stringifer
|
|
14
|
-
*
|
|
15
|
-
* Сreates an instance of Stringifer (Json to String conversion stream)
|
|
16
|
-
*/
|
|
17
|
-
declare class Stringifer extends Transform {
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param start - first separator
|
|
21
|
-
* @param middle - middle separator
|
|
22
|
-
* @param end - end separator
|
|
23
|
-
*/
|
|
24
|
-
constructor(start?: string, middle?: string, end?: string);
|
|
25
|
-
/**
|
|
26
|
-
* separators
|
|
27
|
-
*
|
|
28
|
-
* @private
|
|
29
|
-
*/
|
|
30
|
-
private __separators;
|
|
31
|
-
/**
|
|
32
|
-
* pass string data to the stream
|
|
33
|
-
*
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
private __isString;
|
|
37
|
-
/**
|
|
38
|
-
* stream byte counter
|
|
39
|
-
*
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
private __bytesWrite;
|
|
43
|
-
/**
|
|
44
|
-
* stream encoding
|
|
45
|
-
*
|
|
46
|
-
* @private
|
|
47
|
-
*/
|
|
48
|
-
private __encoding;
|
|
49
|
-
/**
|
|
50
|
-
* Data event handler
|
|
51
|
-
*
|
|
52
|
-
* @private
|
|
53
|
-
* @param object - object data
|
|
54
|
-
* @param encoding - stream encoding
|
|
55
|
-
* @param callback - callback function
|
|
56
|
-
*/
|
|
57
|
-
_transform(object: {
|
|
58
|
-
[key: string]: any;
|
|
59
|
-
} | null | undefined, encoding?: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex", callback?: Function): void;
|
|
60
|
-
/**
|
|
61
|
-
* Flush event handler
|
|
62
|
-
*
|
|
63
|
-
* @private
|
|
64
|
-
* @param callback - callback function
|
|
65
|
-
*/
|
|
66
|
-
_flush(callback?: () => void): void;
|
|
67
|
-
/**
|
|
68
|
-
* End event handler
|
|
69
|
-
*
|
|
70
|
-
* @private
|
|
71
|
-
* @param callback - callback function
|
|
72
|
-
*/
|
|
73
|
-
_final(callback?: () => void): void;
|
|
74
|
-
/**
|
|
75
|
-
* set stream encoding
|
|
76
|
-
*/
|
|
77
|
-
setEncoding: (encoding: "utf8" | "utf-8" | "base64" | "latin1" | "binary" | "hex") => this;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* @class Parser
|
|
81
|
-
*
|
|
82
|
-
* Сreates an instance of Parser (String to Json conversion stream)
|
|
83
|
-
*/
|
|
84
|
-
declare class Parser extends Transform {
|
|
85
|
-
/**
|
|
86
|
-
*
|
|
87
|
-
* @param start - first separator
|
|
88
|
-
* @param middle - middle separator
|
|
89
|
-
* @param end - end separator
|
|
90
|
-
*/
|
|
91
|
-
constructor(start?: string, middle?: string, end?: string);
|
|
92
|
-
/**
|
|
93
|
-
* separators
|
|
94
|
-
*
|
|
95
|
-
* @private
|
|
96
|
-
*/
|
|
97
|
-
private __separators;
|
|
98
|
-
/**
|
|
99
|
-
* empty buffer
|
|
100
|
-
*
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
private static __empty;
|
|
104
|
-
/**
|
|
105
|
-
* stream byte counter
|
|
106
|
-
*
|
|
107
|
-
* @private
|
|
108
|
-
*/
|
|
109
|
-
private __bytesRead;
|
|
110
|
-
/**
|
|
111
|
-
* stream encoding
|
|
112
|
-
*
|
|
113
|
-
* @private
|
|
114
|
-
*/
|
|
115
|
-
private __encoding;
|
|
116
|
-
/**
|
|
117
|
-
* stream buffer
|
|
118
|
-
*
|
|
119
|
-
* @private
|
|
120
|
-
*/
|
|
121
|
-
private __buffers;
|
|
122
|
-
/**
|
|
123
|
-
* left brace counter
|
|
124
|
-
*
|
|
125
|
-
* @private
|
|
126
|
-
*/
|
|
127
|
-
private __leftBrace;
|
|
128
|
-
/**
|
|
129
|
-
* right brace counter
|
|
130
|
-
*
|
|
131
|
-
* @private
|
|
132
|
-
*/
|
|
133
|
-
private __rightBrace;
|
|
134
|
-
/**
|
|
135
|
-
* open quote flag
|
|
136
|
-
*
|
|
137
|
-
* @private
|
|
138
|
-
*/
|
|
139
|
-
private __openQuotes;
|
|
140
|
-
/**
|
|
141
|
-
* clear buffer and reset counters
|
|
142
|
-
*
|
|
143
|
-
* @private
|
|
144
|
-
*/
|
|
145
|
-
private __clear;
|
|
146
|
-
/**
|
|
147
|
-
* basic stream handler
|
|
148
|
-
*/
|
|
149
|
-
private __handler;
|
|
150
|
-
/**
|
|
151
|
-
* Data event handler
|
|
152
|
-
*
|
|
153
|
-
* @private
|
|
154
|
-
* @param string - string or buffer data
|
|
155
|
-
* @param encoding - stream encoding
|
|
156
|
-
* @param callback - callback function
|
|
157
|
-
*/
|
|
158
|
-
_transform(string: string | Buffer | null | undefined, encoding?: "utf8" | "ascii" | "utf-8" | "utf16le" | "ucs2" | "ucs-2" | "base64" | "latin1" | "binary" | "hex", callback?: Function): void;
|
|
159
|
-
/**
|
|
160
|
-
* Flush event handler
|
|
161
|
-
*
|
|
162
|
-
* @private
|
|
163
|
-
* @param callback - callback function
|
|
164
|
-
*/
|
|
165
|
-
_flush(callback?: Function): void;
|
|
166
|
-
/**
|
|
167
|
-
* End event handler
|
|
168
|
-
*
|
|
169
|
-
* @private
|
|
170
|
-
* @param callback - callback function
|
|
171
|
-
*/
|
|
172
|
-
_final(callback?: Function): void;
|
|
173
|
-
/**
|
|
174
|
-
* set stream encoding
|
|
175
|
-
*/
|
|
176
|
-
setEncoding: (encoding: "utf8" | "utf-8" | "base64" | "latin1" | "binary" | "hex") => this;
|
|
177
|
-
}
|
|
10
|
+
import { Parser } from "./classes/Parser";
|
|
11
|
+
import { Stringifer } from "./classes/Stringifer";
|
|
178
12
|
declare const _default: {
|
|
179
13
|
/**
|
|
180
14
|
* Object to String stream
|
|
@@ -186,4 +20,3 @@ declare const _default: {
|
|
|
186
20
|
Parser: typeof Parser;
|
|
187
21
|
};
|
|
188
22
|
export = _default;
|
|
189
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -8,406 +8,16 @@
|
|
|
8
8
|
* @version 2.0.0
|
|
9
9
|
* @requires stream
|
|
10
10
|
*/
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
* Validate object
|
|
14
|
-
*
|
|
15
|
-
* @private
|
|
16
|
-
* @param obj - object for validation
|
|
17
|
-
* @param it - internal flag
|
|
18
|
-
*/
|
|
19
|
-
const validator = (obj, it = true) => {
|
|
20
|
-
switch (typeof (obj)) {
|
|
21
|
-
case "boolean":
|
|
22
|
-
return true;
|
|
23
|
-
case "number":
|
|
24
|
-
return true;
|
|
25
|
-
case "string":
|
|
26
|
-
return true;
|
|
27
|
-
case "object":
|
|
28
|
-
if (obj === null)
|
|
29
|
-
return true;
|
|
30
|
-
if (obj.__proto__ === {}.__proto__) {
|
|
31
|
-
for (const key in obj)
|
|
32
|
-
if (validator(obj[key]) === false)
|
|
33
|
-
return false;
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
if (it && (obj.__proto__ === [].__proto__)) {
|
|
37
|
-
for (const key of obj)
|
|
38
|
-
if (validator(key) === false)
|
|
39
|
-
return false;
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
default:
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
/**
|
|
48
|
-
* @class Stringifer
|
|
49
|
-
*
|
|
50
|
-
* Сreates an instance of Stringifer (Json to String conversion stream)
|
|
51
|
-
*/
|
|
52
|
-
class Stringifer extends stream_1.Transform {
|
|
53
|
-
/**
|
|
54
|
-
*
|
|
55
|
-
* @param start - first separator
|
|
56
|
-
* @param middle - middle separator
|
|
57
|
-
* @param end - end separator
|
|
58
|
-
*/
|
|
59
|
-
constructor(start, middle, end) {
|
|
60
|
-
super({ highWaterMark: 64 * 1024, objectMode: true });
|
|
61
|
-
/**
|
|
62
|
-
* set stream encoding
|
|
63
|
-
*/
|
|
64
|
-
this.setEncoding = (encoding) => {
|
|
65
|
-
this.__encoding = encoding;
|
|
66
|
-
this.setDefaultEncoding(this.__encoding);
|
|
67
|
-
this.__isString = true;
|
|
68
|
-
return this;
|
|
69
|
-
};
|
|
70
|
-
if ((typeof (start) !== "undefined") &&
|
|
71
|
-
((typeof (start) !== "string") ||
|
|
72
|
-
(Buffer.byteLength(start) > 1) ||
|
|
73
|
-
(start.match(/["{}]/))))
|
|
74
|
-
throw new Error("Argument start require one byte String!");
|
|
75
|
-
if ((typeof (middle) !== "undefined") &&
|
|
76
|
-
((typeof (middle) !== "string") ||
|
|
77
|
-
(Buffer.byteLength(middle) > 1) ||
|
|
78
|
-
(middle.match(/["{}]/))))
|
|
79
|
-
throw new Error("Argument separator require one byte String!");
|
|
80
|
-
if ((typeof (end) !== "undefined") &&
|
|
81
|
-
((typeof (end) !== "string") ||
|
|
82
|
-
(Buffer.byteLength(end) > 1) ||
|
|
83
|
-
(end.match(/["{}]/))))
|
|
84
|
-
throw new Error("Argument end require one byte String!");
|
|
85
|
-
this.__separators = {
|
|
86
|
-
start: Buffer.from(start ? start : "", "utf8"),
|
|
87
|
-
middle: Buffer.from(middle ? middle : "", "utf8"),
|
|
88
|
-
end: Buffer.from(end ? end : "", "utf8")
|
|
89
|
-
};
|
|
90
|
-
this.__isString = false;
|
|
91
|
-
this.__bytesWrite = 0;
|
|
92
|
-
this.__encoding = "utf8";
|
|
93
|
-
this.setDefaultEncoding(this.__encoding);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Data event handler
|
|
97
|
-
*
|
|
98
|
-
* @private
|
|
99
|
-
* @param object - object data
|
|
100
|
-
* @param encoding - stream encoding
|
|
101
|
-
* @param callback - callback function
|
|
102
|
-
*/
|
|
103
|
-
_transform(object, encoding = this.__encoding, callback = () => { return; }) {
|
|
104
|
-
if (typeof (object) === "undefined") {
|
|
105
|
-
callback();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
if (object === null) {
|
|
109
|
-
this._final(() => {
|
|
110
|
-
callback();
|
|
111
|
-
});
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
switch (typeof (object)) {
|
|
115
|
-
case "object":
|
|
116
|
-
try {
|
|
117
|
-
if (validator(object, false) !== true) {
|
|
118
|
-
callback([new Error("Validation failed, incoming data type is not pure Object!")]);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
let _buffer = Buffer.from(JSON.stringify(object), "utf8");
|
|
122
|
-
if (this.__bytesWrite === 0) {
|
|
123
|
-
_buffer = Buffer.concat([this.__separators.start, _buffer]);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
_buffer = Buffer.concat([this.__separators.middle, _buffer]);
|
|
127
|
-
}
|
|
128
|
-
if (this.__isString)
|
|
129
|
-
this.push(_buffer.toString(this.__encoding));
|
|
130
|
-
else
|
|
131
|
-
this.push(_buffer, this.__encoding);
|
|
132
|
-
this.__bytesWrite += Buffer.byteLength(_buffer);
|
|
133
|
-
callback();
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
catch (err) {
|
|
137
|
-
callback([err]);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
case "undefined":
|
|
141
|
-
callback();
|
|
142
|
-
return;
|
|
143
|
-
default:
|
|
144
|
-
callback([new Error("Incoming data type is " + typeof (object) + ", require data type is pure Object!")]);
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Flush event handler
|
|
150
|
-
*
|
|
151
|
-
* @private
|
|
152
|
-
* @param callback - callback function
|
|
153
|
-
*/
|
|
154
|
-
_flush(callback = () => { return; }) {
|
|
155
|
-
callback();
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* End event handler
|
|
159
|
-
*
|
|
160
|
-
* @private
|
|
161
|
-
* @param callback - callback function
|
|
162
|
-
*/
|
|
163
|
-
_final(callback = () => { return; }) {
|
|
164
|
-
if (this.__bytesWrite === 0) {
|
|
165
|
-
const _buffer = Buffer.concat([this.__separators.start, this.__separators.end]);
|
|
166
|
-
if (this.__isString)
|
|
167
|
-
this.push(_buffer.toString(this.__encoding));
|
|
168
|
-
else
|
|
169
|
-
this.push(_buffer, this.__encoding);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
if (this.__isString)
|
|
173
|
-
this.push(this.__separators.end.toString(this.__encoding));
|
|
174
|
-
else
|
|
175
|
-
this.push(this.__separators.end, this.__encoding);
|
|
176
|
-
}
|
|
177
|
-
this.__bytesWrite += Buffer.byteLength(this.__separators.end);
|
|
178
|
-
callback();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* @class Parser
|
|
183
|
-
*
|
|
184
|
-
* Сreates an instance of Parser (String to Json conversion stream)
|
|
185
|
-
*/
|
|
186
|
-
class Parser extends stream_1.Transform {
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
* @param start - first separator
|
|
190
|
-
* @param middle - middle separator
|
|
191
|
-
* @param end - end separator
|
|
192
|
-
*/
|
|
193
|
-
constructor(start, middle, end) {
|
|
194
|
-
super({ highWaterMark: 64 * 1024, objectMode: true });
|
|
195
|
-
/**
|
|
196
|
-
* clear buffer and reset counters
|
|
197
|
-
*
|
|
198
|
-
* @private
|
|
199
|
-
*/
|
|
200
|
-
this.__clear = () => {
|
|
201
|
-
this.__buffers = [];
|
|
202
|
-
this.__leftBrace = 0;
|
|
203
|
-
this.__rightBrace = 0;
|
|
204
|
-
this.__openQuotes = false;
|
|
205
|
-
};
|
|
206
|
-
/**
|
|
207
|
-
* basic stream handler
|
|
208
|
-
*/
|
|
209
|
-
this.__handler = (buffer, s, errors) => {
|
|
210
|
-
if (this.__buffers.length > 65536) {
|
|
211
|
-
const _nbuffer = Buffer.concat(this.__buffers);
|
|
212
|
-
this.__buffers = [];
|
|
213
|
-
this.__buffers.push(_nbuffer);
|
|
214
|
-
}
|
|
215
|
-
if (this.__leftBrace !== 0) {
|
|
216
|
-
this.__buffers.push(buffer.slice(s, s + 1));
|
|
217
|
-
}
|
|
218
|
-
else if ((this.__separators.start !== buffer[s]) &&
|
|
219
|
-
(this.__separators.end !== buffer[s]) &&
|
|
220
|
-
(this.__separators.middle !== buffer[s]) &&
|
|
221
|
-
(0x20 !== buffer[s]) &&
|
|
222
|
-
(0x0d !== buffer[s]) &&
|
|
223
|
-
(0x0a !== buffer[s]) &&
|
|
224
|
-
(0x09 !== buffer[s])) {
|
|
225
|
-
errors.push(new Error("Unexpected token " +
|
|
226
|
-
buffer.slice(s, s + 1).toString(this.__encoding) +
|
|
227
|
-
" in JSON at position " + (this.__bytesRead + s)));
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* set stream encoding
|
|
232
|
-
*/
|
|
233
|
-
this.setEncoding = (encoding) => {
|
|
234
|
-
this.__encoding = encoding;
|
|
235
|
-
this.setDefaultEncoding(this.__encoding);
|
|
236
|
-
return this;
|
|
237
|
-
};
|
|
238
|
-
if ((typeof (start) !== "undefined") &&
|
|
239
|
-
((typeof (start) !== "string") ||
|
|
240
|
-
(Buffer.byteLength(start) > 1) ||
|
|
241
|
-
(start.match(/["{}]/))))
|
|
242
|
-
throw new Error("Argument start require one byte String!");
|
|
243
|
-
if ((typeof (middle) !== "undefined") &&
|
|
244
|
-
((typeof (middle) !== "string") ||
|
|
245
|
-
(Buffer.byteLength(middle) > 1) ||
|
|
246
|
-
(middle.match(/["{}]/))))
|
|
247
|
-
throw new Error("Argument separator require one byte String!");
|
|
248
|
-
if ((typeof (end) !== "undefined") &&
|
|
249
|
-
((typeof (end) !== "string") ||
|
|
250
|
-
(Buffer.byteLength(end) > 1) ||
|
|
251
|
-
(end.match(/["{}]/))))
|
|
252
|
-
throw new Error("Argument end require one byte String!");
|
|
253
|
-
this.__separators = {
|
|
254
|
-
start: Buffer.from(start ? start : "", "utf8")[0],
|
|
255
|
-
middle: Buffer.from(middle ? middle : "", "utf8")[0],
|
|
256
|
-
end: Buffer.from(end ? end : "", "utf8")[0]
|
|
257
|
-
};
|
|
258
|
-
this.__clear();
|
|
259
|
-
this.__bytesRead = 0;
|
|
260
|
-
this.__encoding = "utf8";
|
|
261
|
-
this.setDefaultEncoding(this.__encoding);
|
|
262
|
-
this.__buffers = [];
|
|
263
|
-
this.__leftBrace = 0;
|
|
264
|
-
this.__rightBrace = 0;
|
|
265
|
-
this.__openQuotes = false;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Data event handler
|
|
269
|
-
*
|
|
270
|
-
* @private
|
|
271
|
-
* @param string - string or buffer data
|
|
272
|
-
* @param encoding - stream encoding
|
|
273
|
-
* @param callback - callback function
|
|
274
|
-
*/
|
|
275
|
-
_transform(string, encoding = this.__encoding, callback = () => { return; }) {
|
|
276
|
-
if (typeof (string) === "undefined") {
|
|
277
|
-
callback();
|
|
278
|
-
return;
|
|
279
|
-
}
|
|
280
|
-
if (string === null) {
|
|
281
|
-
this._final(() => {
|
|
282
|
-
callback();
|
|
283
|
-
});
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
const _buffer = (typeof (string) === "string") ?
|
|
287
|
-
Buffer.from(string, encoding) : string;
|
|
288
|
-
if (!(_buffer instanceof Buffer)) {
|
|
289
|
-
callback([
|
|
290
|
-
new Error("Incoming data type is " +
|
|
291
|
-
typeof (_buffer) +
|
|
292
|
-
", require data type is String!")
|
|
293
|
-
]);
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
if (Parser.__empty.equals(_buffer)) {
|
|
297
|
-
callback();
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
const errors = [];
|
|
301
|
-
for (let s = 0; s < _buffer.length; s++) {
|
|
302
|
-
switch (_buffer[s]) {
|
|
303
|
-
case 0x7b:
|
|
304
|
-
this.__leftBrace++;
|
|
305
|
-
this.__handler(_buffer, s, errors);
|
|
306
|
-
break;
|
|
307
|
-
case 0x7d:
|
|
308
|
-
this.__rightBrace++;
|
|
309
|
-
this.__handler(_buffer, s, errors);
|
|
310
|
-
break;
|
|
311
|
-
case 0x08:
|
|
312
|
-
case 0x09:
|
|
313
|
-
case 0x0a:
|
|
314
|
-
case 0x0c:
|
|
315
|
-
case 0x0d:
|
|
316
|
-
case 0x00:
|
|
317
|
-
case 0x0b:
|
|
318
|
-
if (this.__openQuotes && (this.__leftBrace !== 0))
|
|
319
|
-
this.__buffers.push(Buffer.from("\\u" + ("0000" + _buffer[s].toString(16)).slice(-4), "utf8"));
|
|
320
|
-
break;
|
|
321
|
-
case 0x22:
|
|
322
|
-
if (_buffer[s - 1] !== 0x5c)
|
|
323
|
-
if (this.__openQuotes)
|
|
324
|
-
this.__openQuotes = false;
|
|
325
|
-
else if (this.__leftBrace !== 0)
|
|
326
|
-
this.__openQuotes = true;
|
|
327
|
-
this.__handler(_buffer, s, errors);
|
|
328
|
-
break;
|
|
329
|
-
default:
|
|
330
|
-
this.__handler(_buffer, s, errors);
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
if ((this.__leftBrace !== 0) && (this.__leftBrace === this.__rightBrace)) {
|
|
334
|
-
try {
|
|
335
|
-
const _buf = Buffer.concat(this.__buffers);
|
|
336
|
-
const _str = _buf.toString("utf8");
|
|
337
|
-
const _object = JSON.parse(_str);
|
|
338
|
-
if (validator(_object, false)) {
|
|
339
|
-
this.__clear();
|
|
340
|
-
this.push(_object);
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
this.__clear();
|
|
344
|
-
errors.push(new Error("Validation failed, incoming data type is not pure Object!"));
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
catch (err) {
|
|
348
|
-
this.__clear();
|
|
349
|
-
errors.push(err);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
else if (this.__leftBrace < this.__rightBrace) {
|
|
353
|
-
this.__clear();
|
|
354
|
-
errors.push(new Error("Parsing error, clear buffer!"));
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (errors.length > 0)
|
|
358
|
-
callback(errors);
|
|
359
|
-
else
|
|
360
|
-
callback();
|
|
361
|
-
this.__bytesRead += _buffer.byteLength;
|
|
362
|
-
}
|
|
363
|
-
/**
|
|
364
|
-
* Flush event handler
|
|
365
|
-
*
|
|
366
|
-
* @private
|
|
367
|
-
* @param callback - callback function
|
|
368
|
-
*/
|
|
369
|
-
_flush(callback = () => { return; }) {
|
|
370
|
-
this.__clear();
|
|
371
|
-
callback();
|
|
372
|
-
}
|
|
373
|
-
/**
|
|
374
|
-
* End event handler
|
|
375
|
-
*
|
|
376
|
-
* @private
|
|
377
|
-
* @param callback - callback function
|
|
378
|
-
*/
|
|
379
|
-
_final(callback = () => { return; }) {
|
|
380
|
-
if (this.__buffers.length === 0) {
|
|
381
|
-
callback();
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
try {
|
|
385
|
-
const _buf = Buffer.concat(this.__buffers);
|
|
386
|
-
const _str = _buf.toString("utf8");
|
|
387
|
-
JSON.parse(_str);
|
|
388
|
-
callback([
|
|
389
|
-
new Error("Raw object detected!")
|
|
390
|
-
]);
|
|
391
|
-
}
|
|
392
|
-
catch (err) {
|
|
393
|
-
callback([err]);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* empty buffer
|
|
399
|
-
*
|
|
400
|
-
* @private
|
|
401
|
-
*/
|
|
402
|
-
Parser.__empty = Buffer.from("");
|
|
11
|
+
const Parser_1 = require("./classes/Parser");
|
|
12
|
+
const Stringifer_1 = require("./classes/Stringifer");
|
|
403
13
|
module.exports = module.exports = {
|
|
404
14
|
/**
|
|
405
15
|
* Object to String stream
|
|
406
16
|
*/
|
|
407
|
-
Stringifer,
|
|
17
|
+
Stringifer: Stringifer_1.Stringifer,
|
|
408
18
|
/**
|
|
409
19
|
* String to Object stream
|
|
410
20
|
*/
|
|
411
|
-
Parser
|
|
21
|
+
Parser: Parser_1.Parser
|
|
412
22
|
};
|
|
413
23
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,mCAAkC;AAElC;;;;;;GAMG;AACH,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,KAAc,IAAI,EAAE,EAAE;IAClD,QAAO,OAAM,CAAC,GAAG,CAAC,EAAC;QAClB,KAAK,SAAS;YACb,OAAO,IAAI,CAAA;QACZ,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAA;QACZ,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAA;QACZ,KAAK,QAAQ;YACZ,IAAG,GAAG,KAAK,IAAI;gBACd,OAAO,IAAI,CAAA;YACZ,IAAG,GAAG,CAAC,SAAS,KAAM,EAAW,CAAC,SAAS,EAAC;gBAC3C,KAAK,MAAM,GAAG,IAAI,GAA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,QAAQ,CAAC,MAAM,CAAC,CAAA;YAC1C,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAChB,QAAQ,CAAC;gBACR,IAAI,KAAK,CAAC,sBAAsB,CAAC;aACjC,CAAC,CAAA;SACF;QAAC,OAAM,GAAG,EAAC;YACX,QAAQ,CAAC,CAAE,GAAG,CAAE,CAAC,CAAA;SACjB;IACF,CAAC;;AA/MD;;;;GAIG;AACY,cAAO,GAAW,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAqNjD,iBAAS,MAAM,CAAC,OAAO,GAAG;IACzB;;OAEG;IACH,UAAU;IACV;;OAEG;IACH,MAAM;CACN,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AAEH,6CAAyC;AACzC,qDAAiD;AAEjD,iBAAS,MAAM,CAAC,OAAO,GAAG;IACzB;;OAEG;IACH,UAAU,EAAV,uBAAU;IACV;;OAEG;IACH,MAAM,EAAN,eAAM;CACN,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validator = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Validate object
|
|
6
|
+
*
|
|
7
|
+
* @private
|
|
8
|
+
* @param obj - object for validation
|
|
9
|
+
* @param it - internal flag
|
|
10
|
+
*/
|
|
11
|
+
const validator = (obj, it = true) => {
|
|
12
|
+
switch (typeof (obj)) {
|
|
13
|
+
case "boolean":
|
|
14
|
+
return true;
|
|
15
|
+
case "number":
|
|
16
|
+
return true;
|
|
17
|
+
case "string":
|
|
18
|
+
return true;
|
|
19
|
+
case "object":
|
|
20
|
+
if (obj === null)
|
|
21
|
+
return true;
|
|
22
|
+
if (obj.__proto__ === {}.__proto__) {
|
|
23
|
+
for (const key in obj)
|
|
24
|
+
if ((0, exports.validator)(obj[key]) === false)
|
|
25
|
+
return false;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (it && (obj.__proto__ === [].__proto__)) {
|
|
29
|
+
for (const key of obj)
|
|
30
|
+
if ((0, exports.validator)(key) === false)
|
|
31
|
+
return false;
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
default:
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.validator = validator;
|
|
40
|
+
//# sourceMappingURL=global.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../../src/utils/global.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACI,MAAM,SAAS,GAAG,CAAC,GAAQ,EAAE,KAAc,IAAI,EAAE,EAAE;IACzD,QAAO,OAAM,CAAC,GAAG,CAAC,EAAC;QAClB,KAAK,SAAS;YACb,OAAO,IAAI,CAAA;QACZ,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAA;QACZ,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAA;QACZ,KAAK,QAAQ;YACZ,IAAG,GAAG,KAAK,IAAI;gBACd,OAAO,IAAI,CAAA;YACZ,IAAG,GAAG,CAAC,SAAS,KAAM,EAAW,CAAC,SAAS,EAAC;gBAC3C,KAAK,MAAM,GAAG,IAAI,GAAG;oBACrB,IAAG,IAAA,iBAAS,EAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;wBAC/B,OAAO,KAAK,CAAA;gBACb,OAAO,IAAI,CAAA;aACX;YACD,IAAG,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,KAAM,EAAU,CAAC,SAAS,CAAC,EAAC;gBAClD,KAAK,MAAM,GAAG,IAAI,GAAG;oBACrB,IAAG,IAAA,iBAAS,EAAC,GAAG,CAAC,KAAK,KAAK;wBAC1B,OAAO,KAAK,CAAA;gBACb,OAAO,IAAI,CAAA;aACX;YACD,OAAO,KAAK,CAAA;QACb;YACC,OAAO,KAAK,CAAA;KACb;AACF,CAAC,CAAA;AA3BY,QAAA,SAAS,aA2BrB"}
|