w-json-stream 1.0.13 → 1.0.16
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/.github/workflows/ci-test.yml +24 -0
- package/.jsdoc +1 -1
- package/LICENSE +1 -1
- package/README.md +2 -3
- package/SECURITY.md +5 -0
- package/dist/into-stream.umd.js +2 -2
- package/dist/into-stream.umd.js.map +1 -1
- package/dist/json-stream-stringify.umd.js +2 -2
- package/dist/json-stream-stringify.umd.js.map +1 -1
- package/dist/through.umd.js +2 -2
- package/dist/through.umd.js.map +1 -1
- package/dist/w-json-stream.umd.js +2 -2
- package/dist/w-json-stream.umd.js.map +1 -1
- package/dist/w-json-stream.wk.umd.js +1 -1
- package/docs/WJsonStream.mjs.html +1 -1
- package/docs/examples/ex-large-webworker.html +2 -2
- package/docs/examples/ex-large.html +2 -2
- package/docs/examples/ex-small-stream.html +2 -2
- package/docs/examples/ex-small.html +2 -2
- package/docs/examples/ex-stream-createParseStream.html +2 -2
- package/docs/examples/ex-stream-createParseStreamWithFilter.html +3 -3
- package/docs/examples/ex-stream-createStringifyStream.html +2 -2
- package/docs/global.html +1 -1
- package/docs/index.html +1 -1
- package/package.json +4 -10
- package/src/from2.mjs +113 -0
- package/src/intoStream.mjs +2 -1
|
@@ -284,7 +284,7 @@ export default WJsonStream
|
|
|
284
284
|
<br class="clear">
|
|
285
285
|
|
|
286
286
|
<footer>
|
|
287
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.
|
|
287
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Aug 26 2022 12:00:29 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
288
288
|
</footer>
|
|
289
289
|
|
|
290
290
|
<script>prettyPrint();</script>
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
12
12
|
|
|
13
|
-
<script _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
14
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
13
|
+
<script _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
14
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
17
|
console.log('WebWorkers(from blob) does not support IE11')
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
12
12
|
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
14
|
-
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
14
|
+
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
17
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
12
12
|
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
14
|
-
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
14
|
+
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
17
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
12
12
|
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
14
|
-
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
14
|
+
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
17
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
12
12
|
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
14
|
-
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
14
|
+
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
17
|
console.log('ReadableStream does not support IE11')
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
|
|
13
13
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
14
14
|
|
|
15
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
16
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
17
|
-
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
15
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/into-stream.umd.js"></script>
|
|
16
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
17
|
+
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
18
18
|
|
|
19
19
|
<script>
|
|
20
20
|
console.log('ReadableStream does not support IE11')
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<script src="https://cdn.jsdelivr.net/npm/wsemi/dist/wsemi.umd.js"></script>
|
|
12
12
|
|
|
13
|
-
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
14
|
-
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.
|
|
13
|
+
<script src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.umd.js"></script>
|
|
14
|
+
<script msg="封裝woker無法回傳stream對象" _src="https://cdn.jsdelivr.net/npm/w-json-stream@1.0.16/dist/w-json-stream.wk.umd.js"></script>
|
|
15
15
|
|
|
16
16
|
<script>
|
|
17
17
|
console.log('WritableStream does not support IE11 and Firefox')
|
package/docs/global.html
CHANGED
|
@@ -1186,7 +1186,7 @@
|
|
|
1186
1186
|
<br class="clear">
|
|
1187
1187
|
|
|
1188
1188
|
<footer>
|
|
1189
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.
|
|
1189
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Aug 26 2022 12:00:29 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
1190
1190
|
</footer>
|
|
1191
1191
|
|
|
1192
1192
|
<script>prettyPrint();</script>
|
package/docs/index.html
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
<br class="clear">
|
|
69
69
|
|
|
70
70
|
<footer>
|
|
71
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.
|
|
71
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Fri Aug 26 2022 12:00:29 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
72
72
|
</footer>
|
|
73
73
|
|
|
74
74
|
<script>prettyPrint();</script>
|
package/package.json
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w-json-stream",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "A tool for JSON parse and stringify by stream and web worker.",
|
|
3
|
+
"version": "1.0.16",
|
|
5
4
|
"main": "dist/w-json-stream.umd.js",
|
|
6
5
|
"dependencies": {
|
|
7
|
-
"from2": "^2.3.0",
|
|
8
6
|
"jsonparse": "^1.3.1",
|
|
9
7
|
"lodash": "^4.17.21",
|
|
10
|
-
"wsemi": "^1.6.
|
|
8
|
+
"wsemi": "^1.6.78"
|
|
11
9
|
},
|
|
12
10
|
"devDependencies": {
|
|
13
|
-
"w-package-tools": "^1.0.
|
|
11
|
+
"w-package-tools": "^1.0.66"
|
|
14
12
|
},
|
|
15
13
|
"scripts": {
|
|
16
14
|
"test": "mocha --parallel --timeout 60000 --experimental-modules --es-module-specifier-resolution=node",
|
|
@@ -35,9 +33,5 @@
|
|
|
35
33
|
"browser"
|
|
36
34
|
],
|
|
37
35
|
"author": "yuda-lyu(semisphere)",
|
|
38
|
-
"license": "MIT"
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/yuda-lyu/w-json-stream/issues"
|
|
41
|
-
},
|
|
42
|
-
"homepage": "https://github.com/yuda-lyu/w-json-stream#readme"
|
|
36
|
+
"license": "MIT"
|
|
43
37
|
}
|
package/src/from2.mjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//fork from: https://github.com/hughsk/from2/blob/master/index.js
|
|
2
|
+
// let Readable = require('readable-stream').Readable
|
|
3
|
+
// let inherits = require('inherits')
|
|
4
|
+
// module.exports = from2
|
|
5
|
+
// import rs from 'readable-stream'
|
|
6
|
+
import { Readable } from 'stream'
|
|
7
|
+
import inherits from 'inherits'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// let Readable = rs.Readable
|
|
11
|
+
|
|
12
|
+
let Proto = ctor()
|
|
13
|
+
|
|
14
|
+
function toFunction(list) {
|
|
15
|
+
list = list.slice()
|
|
16
|
+
return function (_, cb) {
|
|
17
|
+
let err = null
|
|
18
|
+
let item = list.length ? list.shift() : null
|
|
19
|
+
if (item instanceof Error) {
|
|
20
|
+
err = item
|
|
21
|
+
item = null
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
cb(err, item)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function from2(opts, read) {
|
|
29
|
+
if (typeof opts !== 'object' || Array.isArray(opts)) {
|
|
30
|
+
read = opts
|
|
31
|
+
opts = {}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
let rs = new Proto(opts)
|
|
35
|
+
rs._from = Array.isArray(read) ? toFunction(read) : (read || noop)
|
|
36
|
+
return rs
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ctor(opts, read) {
|
|
40
|
+
if (typeof opts === 'function') {
|
|
41
|
+
read = opts
|
|
42
|
+
opts = {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
opts = defaults(opts)
|
|
46
|
+
|
|
47
|
+
inherits(Class, Readable)
|
|
48
|
+
function Class(override) {
|
|
49
|
+
if (!(this instanceof Class)) return new Class(override)
|
|
50
|
+
this._reading = false
|
|
51
|
+
this._callback = check
|
|
52
|
+
this.destroyed = false
|
|
53
|
+
Readable.call(this, override || opts)
|
|
54
|
+
|
|
55
|
+
let self = this
|
|
56
|
+
let hwm = this._readableState.highWaterMark
|
|
57
|
+
|
|
58
|
+
function check(err, data) {
|
|
59
|
+
if (self.destroyed) return
|
|
60
|
+
if (err) return self.destroy(err)
|
|
61
|
+
if (data === null) return self.push(null)
|
|
62
|
+
self._reading = false
|
|
63
|
+
if (self.push(data)) self._read(hwm)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Class.prototype._from = read || noop
|
|
68
|
+
Class.prototype._read = function(size) {
|
|
69
|
+
if (this._reading || this.destroyed) return
|
|
70
|
+
this._reading = true
|
|
71
|
+
this._from(size, this._callback)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
Class.prototype.destroy = function(err) {
|
|
75
|
+
if (this.destroyed) return
|
|
76
|
+
this.destroyed = true
|
|
77
|
+
|
|
78
|
+
let self = this
|
|
79
|
+
process.nextTick(function() {
|
|
80
|
+
if (err) self.emit('error', err)
|
|
81
|
+
self.emit('close')
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return Class
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function obj(opts, read) {
|
|
89
|
+
if (typeof opts === 'function' || Array.isArray(opts)) {
|
|
90
|
+
read = opts
|
|
91
|
+
opts = {}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
opts = defaults(opts)
|
|
95
|
+
opts.objectMode = true
|
|
96
|
+
opts.highWaterMark = 16
|
|
97
|
+
|
|
98
|
+
return from2(opts, read)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function noop () {}
|
|
102
|
+
|
|
103
|
+
function defaults(opts) {
|
|
104
|
+
opts = opts || {}
|
|
105
|
+
return opts
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
//add ctor, obj
|
|
109
|
+
from2.ctor = ctor
|
|
110
|
+
from2.obj = obj
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
export default from2
|
package/src/intoStream.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
//fork from: https://github.com/sindresorhus/into-stream/blob/main/index.js
|
|
2
|
-
import from2 from 'from2'
|
|
2
|
+
// import from2 from 'from2'
|
|
3
|
+
import from2 from './from2.mjs'
|
|
3
4
|
import { Buffer } from 'buffer'
|
|
4
5
|
import { setImmediate } from 'timers'
|
|
5
6
|
import isPromise from 'wsemi/src/ispm.mjs'
|