Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
703dc11c6c | |||
28725d1723 | |||
c77e0f2ba6 | |||
196fb6d396 | |||
df0ddf04b3 | |||
2e1aa4a8ff | |||
bc09033af0 | |||
22df9dfd94 | |||
d48ef6eb43 | |||
9421c652a2 | |||
a6ab15bf1d | |||
00d1455367 | |||
116a281c6c | |||
9bf6f251c4 | |||
e3427c2498 | |||
a400a0a04c | |||
91392e8bd5 | |||
d161d6613a | |||
7a14e67f4f | |||
465ccfec40 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartstream",
|
"name": "@push.rocks/smartstream",
|
||||||
"version": "3.0.16",
|
"version": "3.0.26",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "simplifies access to node streams",
|
"description": "simplifies access to node streams",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -30,6 +30,7 @@
|
|||||||
"@types/node": "^20.9.0"
|
"@types/node": "^20.9.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@push.rocks/lik": "^6.0.12",
|
||||||
"@push.rocks/smartpromise": "^4.0.3",
|
"@push.rocks/smartpromise": "^4.0.3",
|
||||||
"@push.rocks/smartrx": "^3.0.7"
|
"@push.rocks/smartrx": "^3.0.7"
|
||||||
},
|
},
|
||||||
|
66
pnpm-lock.yaml
generated
66
pnpm-lock.yaml
generated
@ -5,6 +5,9 @@ settings:
|
|||||||
excludeLinksFromLockfile: false
|
excludeLinksFromLockfile: false
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@push.rocks/lik':
|
||||||
|
specifier: ^6.0.12
|
||||||
|
version: 6.0.12
|
||||||
'@push.rocks/smartpromise':
|
'@push.rocks/smartpromise':
|
||||||
specifier: ^4.0.3
|
specifier: ^4.0.3
|
||||||
version: 4.0.3
|
version: 4.0.3
|
||||||
@ -43,7 +46,7 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
'@api.global/typedrequest-interfaces': 3.0.1
|
'@api.global/typedrequest-interfaces': 3.0.1
|
||||||
'@push.rocks/isounique': 1.0.5
|
'@push.rocks/isounique': 1.0.5
|
||||||
'@push.rocks/lik': 6.0.6
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartpromise': 4.0.3
|
'@push.rocks/smartpromise': 4.0.3
|
||||||
'@push.rocks/webrequest': 3.0.34
|
'@push.rocks/webrequest': 3.0.34
|
||||||
@ -55,7 +58,7 @@ packages:
|
|||||||
'@api.global/typedrequest': 3.0.2
|
'@api.global/typedrequest': 3.0.2
|
||||||
'@api.global/typedrequest-interfaces': 3.0.1
|
'@api.global/typedrequest-interfaces': 3.0.1
|
||||||
'@api.global/typedsocket': 3.0.0
|
'@api.global/typedsocket': 3.0.0
|
||||||
'@push.rocks/lik': 6.0.6
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartchok': 1.0.23
|
'@push.rocks/smartchok': 1.0.23
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartenv': 5.0.12
|
'@push.rocks/smartenv': 5.0.12
|
||||||
@ -573,21 +576,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-Z0BVqZZOCif1THTbIKWMgg0wxCzt9CyBtBBqQJiZ+jJ0KlQFrQHNHrPt81/LXe/L4x0cxWsn0bpL6W5DNSvNLw==}
|
resolution: {integrity: sha512-Z0BVqZZOCif1THTbIKWMgg0wxCzt9CyBtBBqQJiZ+jJ0KlQFrQHNHrPt81/LXe/L4x0cxWsn0bpL6W5DNSvNLw==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@push.rocks/lik@6.0.5:
|
/@push.rocks/lik@6.0.12:
|
||||||
resolution: {integrity: sha512-rDSPVknpJDcY3yx4w3lNQfpRkBRuxYVIJKrkiODdH27X0z3+XU4e/iAWKySuLq6H7dAoxSHJDf6BrCO+3Y8kcw==}
|
resolution: {integrity: sha512-/vzlOZ26gCmXZz67LeM2hJ+aNM49Jxvf3FKxLMXHhJwffd3LcV96MYbMfKzKR/za/bh5Itf3a6UjLL5mmN6Pew==}
|
||||||
dependencies:
|
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
|
||||||
'@push.rocks/smartmatch': 2.0.0
|
|
||||||
'@push.rocks/smartpromise': 4.0.3
|
|
||||||
'@push.rocks/smartrx': 3.0.7
|
|
||||||
'@push.rocks/smarttime': 4.0.6
|
|
||||||
'@types/minimatch': 5.1.2
|
|
||||||
'@types/symbol-tree': 3.2.4
|
|
||||||
symbol-tree: 3.2.4
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@push.rocks/lik@6.0.6:
|
|
||||||
resolution: {integrity: sha512-5NVFbtR2XsGHxNqUbjFPp91J7mCWFPUc8bVfXIY2YgzhK/I5XI7yT+QBM+Bc2IvGLxjvQPkueRfPKl1IEnegeA==}
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartmatch': 2.0.0
|
'@push.rocks/smartmatch': 2.0.0
|
||||||
@ -597,7 +587,6 @@ packages:
|
|||||||
'@types/minimatch': 5.1.2
|
'@types/minimatch': 5.1.2
|
||||||
'@types/symbol-tree': 3.2.5
|
'@types/symbol-tree': 3.2.5
|
||||||
symbol-tree: 3.2.4
|
symbol-tree: 3.2.4
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@push.rocks/smartbrowser@2.0.6:
|
/@push.rocks/smartbrowser@2.0.6:
|
||||||
resolution: {integrity: sha512-Ne+KCVhV/DROc1rHRRw59K6h0+LpQAK9fdOUtgDZ7laLPmB/tmnbUh3IuRDNcIY1iVA9pydoobwjnTjVgio9eQ==}
|
resolution: {integrity: sha512-Ne+KCVhV/DROc1rHRRw59K6h0+LpQAK9fdOUtgDZ7laLPmB/tmnbUh3IuRDNcIY1iVA9pydoobwjnTjVgio9eQ==}
|
||||||
@ -636,7 +625,7 @@ packages:
|
|||||||
/@push.rocks/smartcli@4.0.8:
|
/@push.rocks/smartcli@4.0.8:
|
||||||
resolution: {integrity: sha512-B4F3nqq7ko8tev1wxGdFnh/zSDDP8Q9LpEOb3wTf0jayyhYetFQ7n6zi4J9fhXYBKPkJSyQEBoOfRmgJyeLHkA==}
|
resolution: {integrity: sha512-B4F3nqq7ko8tev1wxGdFnh/zSDDP8Q9LpEOb3wTf0jayyhYetFQ7n6zi4J9fhXYBKPkJSyQEBoOfRmgJyeLHkA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.0.5
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartlog': 3.0.3
|
'@push.rocks/smartlog': 3.0.3
|
||||||
'@push.rocks/smartparam': 1.1.10
|
'@push.rocks/smartparam': 1.1.10
|
||||||
'@push.rocks/smartpromise': 4.0.3
|
'@push.rocks/smartpromise': 4.0.3
|
||||||
@ -648,7 +637,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-mUuI7kj2f7ztjpic96FvRIlf2RsKBa5arw81AHNsndbxO6asRcxuWL8dTVxouEIK8YsBUlj0AsrCkHhMbLQdHw==}
|
resolution: {integrity: sha512-mUuI7kj2f7ztjpic96FvRIlf2RsKBa5arw81AHNsndbxO6asRcxuWL8dTVxouEIK8YsBUlj0AsrCkHhMbLQdHw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/smartpromise': 4.0.3
|
'@push.rocks/smartpromise': 4.0.3
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@push.rocks/smartenv@5.0.10:
|
/@push.rocks/smartenv@5.0.10:
|
||||||
resolution: {integrity: sha512-yJURKoz5awTPyN+5MO1A9maf5+Zh2qutHlbZPx2y5P6rwGPFWThippLicqXUSs2rM49ES6RKAD48Q8w5GQkWFw==}
|
resolution: {integrity: sha512-yJURKoz5awTPyN+5MO1A9maf5+Zh2qutHlbZPx2y5P6rwGPFWThippLicqXUSs2rM49ES6RKAD48Q8w5GQkWFw==}
|
||||||
@ -685,7 +673,7 @@ packages:
|
|||||||
/@push.rocks/smartfile@10.0.41:
|
/@push.rocks/smartfile@10.0.41:
|
||||||
resolution: {integrity: sha512-xOOy0duI34M2qrJZggpk51EHGXmg9+mBL1Q55tNiQKXzfx89P3coY1EAZG8tvmep3qB712QEKe7T+u04t42Kjg==}
|
resolution: {integrity: sha512-xOOy0duI34M2qrJZggpk51EHGXmg9+mBL1Q55tNiQKXzfx89P3coY1EAZG8tvmep3qB712QEKe7T+u04t42Kjg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.0.5
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartfile-interfaces': 1.0.7
|
'@push.rocks/smartfile-interfaces': 1.0.7
|
||||||
'@push.rocks/smarthash': 3.0.4
|
'@push.rocks/smarthash': 3.0.4
|
||||||
@ -706,7 +694,7 @@ packages:
|
|||||||
/@push.rocks/smartfile@11.0.0:
|
/@push.rocks/smartfile@11.0.0:
|
||||||
resolution: {integrity: sha512-S2JyuRiBu6tocKGTbdLgz0NcGuJ2fP7mD+NHryqdnvXzIwapE1jZ1XAF8/xiLuB9rmIs7agKFm+2Jj3/PtfIWw==}
|
resolution: {integrity: sha512-S2JyuRiBu6tocKGTbdLgz0NcGuJ2fP7mD+NHryqdnvXzIwapE1jZ1XAF8/xiLuB9rmIs7agKFm+2Jj3/PtfIWw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.0.6
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartfile-interfaces': 1.0.7
|
'@push.rocks/smartfile-interfaces': 1.0.7
|
||||||
'@push.rocks/smarthash': 3.0.4
|
'@push.rocks/smarthash': 3.0.4
|
||||||
@ -778,7 +766,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-MBzP++1yNIBeox71X6VxpIgZ8m4bXnJpZJ4nWVH6IWpmO38MXTu4X0QF8tQnyT4LFcwvc9iiWaD15cstHa7Mmw==}
|
resolution: {integrity: sha512-MBzP++1yNIBeox71X6VxpIgZ8m4bXnJpZJ4nWVH6IWpmO38MXTu4X0QF8tQnyT4LFcwvc9iiWaD15cstHa7Mmw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
matcher: 5.0.0
|
matcher: 5.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@push.rocks/smartmime@1.0.6:
|
/@push.rocks/smartmime@1.0.6:
|
||||||
resolution: {integrity: sha512-PHd+I4UcsnOATNg8wjDsSAmmJ4CwQFrQCNzd0HSJMs4ZpiK3Ya91almd6GLpDPU370U4HFh4FaPF4eEAI6vkJQ==}
|
resolution: {integrity: sha512-PHd+I4UcsnOATNg8wjDsSAmmJ4CwQFrQCNzd0HSJMs4ZpiK3Ya91almd6GLpDPU370U4HFh4FaPF4eEAI6vkJQ==}
|
||||||
@ -909,7 +896,7 @@ packages:
|
|||||||
'@api.global/typedserver': 3.0.9
|
'@api.global/typedserver': 3.0.9
|
||||||
'@push.rocks/isohash': 2.0.1
|
'@push.rocks/isohash': 2.0.1
|
||||||
'@push.rocks/isounique': 1.0.5
|
'@push.rocks/isounique': 1.0.5
|
||||||
'@push.rocks/lik': 6.0.6
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartenv': 5.0.12
|
'@push.rocks/smartenv': 5.0.12
|
||||||
'@push.rocks/smartjson': 5.0.10
|
'@push.rocks/smartjson': 5.0.10
|
||||||
@ -973,14 +960,13 @@ packages:
|
|||||||
/@push.rocks/smarttime@4.0.6:
|
/@push.rocks/smarttime@4.0.6:
|
||||||
resolution: {integrity: sha512-1whOow0YJw/TbN758TedRRxApoZbsvyxCVpoGjXh7DE/fEEgs7RCr4vVF5jYpyXNQuNMLpKJcTsSfyQ6RvH4Aw==}
|
resolution: {integrity: sha512-1whOow0YJw/TbN758TedRRxApoZbsvyxCVpoGjXh7DE/fEEgs7RCr4vVF5jYpyXNQuNMLpKJcTsSfyQ6RvH4Aw==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@push.rocks/lik': 6.0.5
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartdelay': 3.0.5
|
'@push.rocks/smartdelay': 3.0.5
|
||||||
'@push.rocks/smartpromise': 4.0.3
|
'@push.rocks/smartpromise': 4.0.3
|
||||||
croner: 7.0.4
|
croner: 7.0.4
|
||||||
dayjs: 1.11.10
|
dayjs: 1.11.10
|
||||||
is-nan: 1.3.2
|
is-nan: 1.3.2
|
||||||
pretty-ms: 8.0.0
|
pretty-ms: 8.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@push.rocks/smartunique@3.0.6:
|
/@push.rocks/smartunique@3.0.6:
|
||||||
resolution: {integrity: sha512-/fvh5BBHiTvZcCH4km2Oh3f0spfcWKr7e0Dp6lAb3rJq+5KiO7fQmI1UcQ9clADUaaJOn8sPzseiLt+kJ2tajw==}
|
resolution: {integrity: sha512-/fvh5BBHiTvZcCH4km2Oh3f0spfcWKr7e0Dp6lAb3rJq+5KiO7fQmI1UcQ9clADUaaJOn8sPzseiLt+kJ2tajw==}
|
||||||
@ -1037,7 +1023,7 @@ packages:
|
|||||||
resolution: {integrity: sha512-w5Q3g1TT5SDIXukAAoYVuWud+Y5ysS8qiBqPU00/re895VVZhUOSNJMNU6jyneZigmbWtwSLsxDkZHlsHWpfuA==}
|
resolution: {integrity: sha512-w5Q3g1TT5SDIXukAAoYVuWud+Y5ysS8qiBqPU00/re895VVZhUOSNJMNU6jyneZigmbWtwSLsxDkZHlsHWpfuA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@apiglobal/typedrequest-interfaces': 2.0.1
|
'@apiglobal/typedrequest-interfaces': 2.0.1
|
||||||
'@push.rocks/lik': 6.0.6
|
'@push.rocks/lik': 6.0.12
|
||||||
'@push.rocks/smartenv': 5.0.12
|
'@push.rocks/smartenv': 5.0.12
|
||||||
'@push.rocks/smartjson': 5.0.10
|
'@push.rocks/smartjson': 5.0.10
|
||||||
'@push.rocks/smartpromise': 4.0.3
|
'@push.rocks/smartpromise': 4.0.3
|
||||||
@ -1664,7 +1650,6 @@ packages:
|
|||||||
|
|
||||||
/@types/minimatch@5.1.2:
|
/@types/minimatch@5.1.2:
|
||||||
resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==}
|
resolution: {integrity: sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@types/mocha@5.2.7:
|
/@types/mocha@5.2.7:
|
||||||
resolution: {integrity: sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==}
|
resolution: {integrity: sha512-NYrtPht0wGzhwe9+/idPaBB+TqkY9AhTvOLMkThm0IoEfLaiVQZwBwyJ5puCkO3AUCWrmcoePjp2mbFocKy4SQ==}
|
||||||
@ -1763,13 +1748,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-GDV68H0mBSN449sa5HEj51E0wfpVQb8xNSMzxf/PrypMFcLTMwJMOM/cgXiv71Mq5drkOQmUGvL1okOZcu6RrQ==}
|
resolution: {integrity: sha512-GDV68H0mBSN449sa5HEj51E0wfpVQb8xNSMzxf/PrypMFcLTMwJMOM/cgXiv71Mq5drkOQmUGvL1okOZcu6RrQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/symbol-tree@3.2.4:
|
|
||||||
resolution: {integrity: sha512-j9qIwMi0fGQLssA0/06i8XfqCq9eKsbTu+c9uPx1T9zWisSaFWEE2CwJccn/idKCllXUeHaMSeH/i4HQ6JKEAg==}
|
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@types/symbol-tree@3.2.5:
|
/@types/symbol-tree@3.2.5:
|
||||||
resolution: {integrity: sha512-zXnnyENt1TYQcS21MkPaJCVjfcPq7p7yc5mo5JACuumXp6sly5jnlS0IokHd+xmmuCbx6V7JqkMBpswR+nZAcw==}
|
resolution: {integrity: sha512-zXnnyENt1TYQcS21MkPaJCVjfcPq7p7yc5mo5JACuumXp6sly5jnlS0IokHd+xmmuCbx6V7JqkMBpswR+nZAcw==}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/@types/through2@2.0.40:
|
/@types/through2@2.0.40:
|
||||||
resolution: {integrity: sha512-QeEwyeGxvtKjP0I/SR8pHtKMgmqotWTI8V/rNMTjbF3arWZJV/kYtbZXtwQKxUuV/oPSGkUilSspFKkTgCPTpA==}
|
resolution: {integrity: sha512-QeEwyeGxvtKjP0I/SR8pHtKMgmqotWTI8V/rNMTjbF3arWZJV/kYtbZXtwQKxUuV/oPSGkUilSspFKkTgCPTpA==}
|
||||||
@ -2263,7 +2243,6 @@ packages:
|
|||||||
function-bind: 1.1.2
|
function-bind: 1.1.2
|
||||||
get-intrinsic: 1.2.2
|
get-intrinsic: 1.2.2
|
||||||
set-function-length: 1.1.1
|
set-function-length: 1.1.1
|
||||||
dev: true
|
|
||||||
|
|
||||||
/callsites@3.1.0:
|
/callsites@3.1.0:
|
||||||
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
|
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
|
||||||
@ -2501,7 +2480,6 @@ packages:
|
|||||||
/croner@7.0.4:
|
/croner@7.0.4:
|
||||||
resolution: {integrity: sha512-P8Zd88km8oQ0xH8Es0u75GtOnFyCNopuAhlFv5kAnbcTuXd0xNvRTgnxnJEs63FicCOsHTL7rpu4BHzY3cMq4w==}
|
resolution: {integrity: sha512-P8Zd88km8oQ0xH8Es0u75GtOnFyCNopuAhlFv5kAnbcTuXd0xNvRTgnxnJEs63FicCOsHTL7rpu4BHzY3cMq4w==}
|
||||||
engines: {node: '>=6.0'}
|
engines: {node: '>=6.0'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/cross-fetch@3.1.5:
|
/cross-fetch@3.1.5:
|
||||||
resolution: {integrity: sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==}
|
resolution: {integrity: sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==}
|
||||||
@ -2529,7 +2507,6 @@ packages:
|
|||||||
|
|
||||||
/dayjs@1.11.10:
|
/dayjs@1.11.10:
|
||||||
resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
|
resolution: {integrity: sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/debounce@1.2.1:
|
/debounce@1.2.1:
|
||||||
resolution: {integrity: sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==}
|
resolution: {integrity: sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==}
|
||||||
@ -2617,7 +2594,6 @@ packages:
|
|||||||
get-intrinsic: 1.2.2
|
get-intrinsic: 1.2.2
|
||||||
gopd: 1.0.1
|
gopd: 1.0.1
|
||||||
has-property-descriptors: 1.0.1
|
has-property-descriptors: 1.0.1
|
||||||
dev: true
|
|
||||||
|
|
||||||
/define-lazy-prop@2.0.0:
|
/define-lazy-prop@2.0.0:
|
||||||
resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==}
|
resolution: {integrity: sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og==}
|
||||||
@ -2631,7 +2607,6 @@ packages:
|
|||||||
define-data-property: 1.1.1
|
define-data-property: 1.1.1
|
||||||
has-property-descriptors: 1.0.1
|
has-property-descriptors: 1.0.1
|
||||||
object-keys: 1.1.1
|
object-keys: 1.1.1
|
||||||
dev: true
|
|
||||||
|
|
||||||
/delayed-stream@1.0.0:
|
/delayed-stream@1.0.0:
|
||||||
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
|
resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=}
|
||||||
@ -2904,7 +2879,6 @@ packages:
|
|||||||
/escape-string-regexp@5.0.0:
|
/escape-string-regexp@5.0.0:
|
||||||
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
|
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/esm@3.2.25:
|
/esm@3.2.25:
|
||||||
resolution: {integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==}
|
resolution: {integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==}
|
||||||
@ -3164,7 +3138,6 @@ packages:
|
|||||||
|
|
||||||
/function-bind@1.1.2:
|
/function-bind@1.1.2:
|
||||||
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/function.prototype.name@1.1.6:
|
/function.prototype.name@1.1.6:
|
||||||
resolution: {integrity: sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==}
|
resolution: {integrity: sha512-Z5kx79swU5P27WEayXM1tBi5Ze/lbIyiNgU3qyXUOf9b2rgXYyF9Dy9Cx+IQv/Lc8WCG6L82zwUPpSS9hGehIg==}
|
||||||
@ -3196,7 +3169,6 @@ packages:
|
|||||||
has-proto: 1.0.1
|
has-proto: 1.0.1
|
||||||
has-symbols: 1.0.3
|
has-symbols: 1.0.3
|
||||||
hasown: 2.0.0
|
hasown: 2.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/get-stream@5.2.0:
|
/get-stream@5.2.0:
|
||||||
resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==}
|
resolution: {integrity: sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==}
|
||||||
@ -3282,7 +3254,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
|
resolution: {integrity: sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
get-intrinsic: 1.2.2
|
get-intrinsic: 1.2.2
|
||||||
dev: true
|
|
||||||
|
|
||||||
/got@12.6.1:
|
/got@12.6.1:
|
||||||
resolution: {integrity: sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ==}
|
resolution: {integrity: sha512-mThBblvlAF1d4O5oqyvN+ZxLAYwIJK7bpMxgYqPD9okW0C3qm5FFn7k811QrcuEBwaogR3ngOFoCfs6mRv7teQ==}
|
||||||
@ -3328,17 +3299,14 @@ packages:
|
|||||||
resolution: {integrity: sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==}
|
resolution: {integrity: sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==}
|
||||||
dependencies:
|
dependencies:
|
||||||
get-intrinsic: 1.2.2
|
get-intrinsic: 1.2.2
|
||||||
dev: true
|
|
||||||
|
|
||||||
/has-proto@1.0.1:
|
/has-proto@1.0.1:
|
||||||
resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==}
|
resolution: {integrity: sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/has-symbols@1.0.3:
|
/has-symbols@1.0.3:
|
||||||
resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
|
resolution: {integrity: sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/has-tostringtag@1.0.0:
|
/has-tostringtag@1.0.0:
|
||||||
resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==}
|
resolution: {integrity: sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==}
|
||||||
@ -3352,7 +3320,6 @@ packages:
|
|||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
dependencies:
|
dependencies:
|
||||||
function-bind: 1.1.2
|
function-bind: 1.1.2
|
||||||
dev: true
|
|
||||||
|
|
||||||
/he@1.2.0:
|
/he@1.2.0:
|
||||||
resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}
|
resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==}
|
||||||
@ -3607,7 +3574,6 @@ packages:
|
|||||||
dependencies:
|
dependencies:
|
||||||
call-bind: 1.0.5
|
call-bind: 1.0.5
|
||||||
define-properties: 1.2.1
|
define-properties: 1.2.1
|
||||||
dev: true
|
|
||||||
|
|
||||||
/is-negative-zero@2.0.2:
|
/is-negative-zero@2.0.2:
|
||||||
resolution: {integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==}
|
resolution: {integrity: sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==}
|
||||||
@ -4088,7 +4054,6 @@ packages:
|
|||||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||||
dependencies:
|
dependencies:
|
||||||
escape-string-regexp: 5.0.0
|
escape-string-regexp: 5.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/math-random@1.0.4:
|
/math-random@1.0.4:
|
||||||
resolution: {integrity: sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==}
|
resolution: {integrity: sha512-rUxjysqif/BZQH2yhd5Aaq7vXMSx9NdEsQcyA07uEzIvxgI7zIr33gGsh+RU0/XjmQpCW7RsVof1vlkvQVCK5A==}
|
||||||
@ -4340,7 +4305,6 @@ packages:
|
|||||||
/object-keys@1.1.1:
|
/object-keys@1.1.1:
|
||||||
resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==}
|
resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==}
|
||||||
engines: {node: '>= 0.4'}
|
engines: {node: '>= 0.4'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/object.assign@4.1.0:
|
/object.assign@4.1.0:
|
||||||
resolution: {integrity: sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==}
|
resolution: {integrity: sha512-exHJeq6kBKj58mqGyTQ9DFvrZC/eR6OwxzoM9YRoGBqrXYonaFyGiFMuc9VZrXf7DarreEwMpurG3dd+CNyW5w==}
|
||||||
@ -4472,7 +4436,6 @@ packages:
|
|||||||
/parse-ms@3.0.0:
|
/parse-ms@3.0.0:
|
||||||
resolution: {integrity: sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==}
|
resolution: {integrity: sha512-Tpb8Z7r7XbbtBTrM9UhpkzzaMrqA2VXMT3YChzYltwV3P3pM6t8wl7TvpMnSTosz1aQAdVib7kdoys7vYOPerw==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/parse5@6.0.1:
|
/parse5@6.0.1:
|
||||||
resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==}
|
resolution: {integrity: sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==}
|
||||||
@ -4591,7 +4554,6 @@ packages:
|
|||||||
engines: {node: '>=14.16'}
|
engines: {node: '>=14.16'}
|
||||||
dependencies:
|
dependencies:
|
||||||
parse-ms: 3.0.0
|
parse-ms: 3.0.0
|
||||||
dev: true
|
|
||||||
|
|
||||||
/process-nextick-args@2.0.1:
|
/process-nextick-args@2.0.1:
|
||||||
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
||||||
@ -4939,7 +4901,6 @@ packages:
|
|||||||
get-intrinsic: 1.2.2
|
get-intrinsic: 1.2.2
|
||||||
gopd: 1.0.1
|
gopd: 1.0.1
|
||||||
has-property-descriptors: 1.0.1
|
has-property-descriptors: 1.0.1
|
||||||
dev: true
|
|
||||||
|
|
||||||
/set-function-name@2.0.1:
|
/set-function-name@2.0.1:
|
||||||
resolution: {integrity: sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==}
|
resolution: {integrity: sha512-tMNCiqYVkXIZgc2Hnoy2IvC/f8ezc5koaRFkCjrpWzGpCd3qbZXPzVy9MAZzK1ch/X0jvSkojys3oqJN0qCmdA==}
|
||||||
@ -5257,7 +5218,6 @@ packages:
|
|||||||
|
|
||||||
/symbol-tree@3.2.4:
|
/symbol-tree@3.2.4:
|
||||||
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
|
resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==}
|
||||||
dev: true
|
|
||||||
|
|
||||||
/systeminformation@5.21.16:
|
/systeminformation@5.21.16:
|
||||||
resolution: {integrity: sha512-WJZdc5RbmDF1VOJcS+G2oIBeNgmMTyJ8+enHe9stIyBg2XhboUTsSfN9HrFMDV+fgXwJ50kNKgD3TzodsFgB+g==}
|
resolution: {integrity: sha512-WJZdc5RbmDF1VOJcS+G2oIBeNgmMTyJ8+enHe9stIyBg2XhboUTsSfN9HrFMDV+fgXwJ50kNKgD3TzodsFgB+g==}
|
||||||
|
68
test/test.backpressure.ts
Normal file
68
test/test.backpressure.ts
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
import { SmartDuplex, type ISmartDuplexOptions, StreamWrapper } from '../ts/index.js';
|
||||||
|
|
||||||
|
tap.test('should run backpressure test', async (toolsArg) => {
|
||||||
|
const done = toolsArg.defer();
|
||||||
|
async function testBackpressure() {
|
||||||
|
const stream1 = new SmartDuplex({
|
||||||
|
name: 'stream1',
|
||||||
|
objectMode: true,
|
||||||
|
writeFunction: async (chunk, tools) => {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 10)); // Slow processing
|
||||||
|
console.log(`processed chunk ${chunk} in stream 1`);
|
||||||
|
return chunk; // Fast processing
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const stream2 = new SmartDuplex({
|
||||||
|
name: 'stream2',
|
||||||
|
objectMode: true,
|
||||||
|
writeFunction: async (chunk, tools) => {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 20)); // Slow processing
|
||||||
|
console.log(`processed chunk ${chunk} in stream 2`);
|
||||||
|
// await tools.push(chunk);
|
||||||
|
return chunk;
|
||||||
|
},
|
||||||
|
}); // This stream processes data more slowly
|
||||||
|
const stream3 = new SmartDuplex({
|
||||||
|
objectMode: true,
|
||||||
|
name: 'stream3',
|
||||||
|
writeFunction: async (chunk, tools) => {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100)); // Slow processing
|
||||||
|
console.log(`processed chunk ${chunk} in stream 3`);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
stream1.pipe(stream2).pipe(stream3);
|
||||||
|
|
||||||
|
let backpressured = false;
|
||||||
|
for (let i = 0; i < 200; i++) {
|
||||||
|
const canContinue = stream1.write(`Chunk ${i}`, 'utf8');
|
||||||
|
if (!canContinue) {
|
||||||
|
backpressured = true;
|
||||||
|
console.log(`Backpressure at chunk ${i}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stream1.end();
|
||||||
|
|
||||||
|
stream1.on('finish', () => {
|
||||||
|
console.log('Stream 1 finished processing.');
|
||||||
|
});
|
||||||
|
stream2.on('finish', () => {
|
||||||
|
console.log('Stream 2 finished processing.');
|
||||||
|
});
|
||||||
|
stream3.on('finish', () => {
|
||||||
|
console.log('Stream 3 finished processing.');
|
||||||
|
if (!backpressured) {
|
||||||
|
throw new Error('No backpressure was observed.');
|
||||||
|
} else {
|
||||||
|
done.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
testBackpressure();
|
||||||
|
await done.promise;
|
||||||
|
});
|
||||||
|
|
||||||
|
await tap.start();
|
@ -5,9 +5,7 @@ import * as fs from 'fs';
|
|||||||
|
|
||||||
tap.test('should create a SmartStream from a Buffer', async () => {
|
tap.test('should create a SmartStream from a Buffer', async () => {
|
||||||
const bufferData = Buffer.from('This is a test buffer');
|
const bufferData = Buffer.from('This is a test buffer');
|
||||||
const smartStream = SmartDuplex.fromBuffer(bufferData, {
|
const smartStream = SmartDuplex.fromBuffer(bufferData, {});
|
||||||
handleBackpressure: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
let receivedData = Buffer.alloc(0);
|
let receivedData = Buffer.alloc(0);
|
||||||
|
|
||||||
@ -23,26 +21,4 @@ tap.test('should create a SmartStream from a Buffer', async () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a SmartStream from an Observable', async () => {
|
|
||||||
const observableData = 'Observable test data';
|
|
||||||
const testObservable = smartrx.rxjs.of(Buffer.from(observableData));
|
|
||||||
|
|
||||||
const smartStream = SmartDuplex.fromObservable(testObservable, {
|
|
||||||
handleBackpressure: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
let receivedData = Buffer.alloc(0);
|
|
||||||
|
|
||||||
return new Promise<void>((resolve) => {
|
|
||||||
smartStream.on('data', (chunk: Buffer) => {
|
|
||||||
receivedData = Buffer.concat([receivedData, chunk]);
|
|
||||||
});
|
|
||||||
|
|
||||||
smartStream.on('end', () => {
|
|
||||||
expect(receivedData.toString()).toEqual(observableData);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -29,7 +29,7 @@ tap.test('should handle a read stream', async (tools) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
// await streamWrapper.run();
|
await streamWrapper.run();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a valid Intake', async (tools) => {
|
tap.test('should create a valid Intake', async (tools) => {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartstream',
|
name: '@push.rocks/smartstream',
|
||||||
version: '3.0.16',
|
version: '3.0.26',
|
||||||
description: 'simplifies access to node streams'
|
description: 'simplifies access to node streams'
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { Duplex, type DuplexOptions } from 'stream';
|
|||||||
|
|
||||||
export interface IStreamTools {
|
export interface IStreamTools {
|
||||||
truncate: () => void;
|
truncate: () => void;
|
||||||
push: (pipeObject: any) => void;
|
push: (pipeObject: any) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IStreamWriteFunction<T, rT> {
|
export interface IStreamWriteFunction<T, rT> {
|
||||||
@ -15,7 +15,8 @@ export interface IStreamFinalFunction<rT> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ISmartDuplexOptions<TInput, TOutput> extends DuplexOptions {
|
export interface ISmartDuplexOptions<TInput, TOutput> extends DuplexOptions {
|
||||||
handleBackpressure?: boolean;
|
debug?: boolean;
|
||||||
|
name?: string;
|
||||||
readFunction?: () => Promise<void>;
|
readFunction?: () => Promise<void>;
|
||||||
writeFunction?: IStreamWriteFunction<TInput, TOutput>;
|
writeFunction?: IStreamWriteFunction<TInput, TOutput>;
|
||||||
finalFunction?: IStreamFinalFunction<TOutput>;
|
finalFunction?: IStreamFinalFunction<TOutput>;
|
||||||
@ -33,158 +34,104 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
|
|||||||
return smartDuplex;
|
return smartDuplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static fromObservable(
|
|
||||||
observable: plugins.smartrx.rxjs.Observable<any>,
|
|
||||||
options?: ISmartDuplexOptions<any, any>
|
|
||||||
): SmartDuplex {
|
|
||||||
const smartStream = new SmartDuplex(options);
|
|
||||||
smartStream.observableSubscription = observable.subscribe({
|
|
||||||
next: (data) => {
|
|
||||||
if (!smartStream.push(data) && smartStream.handleBackpressure) {
|
|
||||||
// Pause the observable if the stream buffer is full
|
|
||||||
smartStream.observableSubscription?.unsubscribe();
|
|
||||||
smartStream.once('drain', () => {
|
|
||||||
// Resume the observable when the stream buffer is drained
|
|
||||||
smartStream.observableSubscription?.unsubscribe();
|
|
||||||
smartStream.observableSubscription = observable.subscribe((data) => {
|
|
||||||
smartStream.push(data);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: (err) => {
|
|
||||||
smartStream.emit('error', err);
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
smartStream.push(null); // Signal the end of the data
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return smartStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
static fromReplaySubject(
|
|
||||||
replaySubject: plugins.smartrx.rxjs.ReplaySubject<any>,
|
|
||||||
options?: DuplexOptions
|
|
||||||
): SmartDuplex {
|
|
||||||
const smartStream = new SmartDuplex(options);
|
|
||||||
let isBackpressured = false;
|
|
||||||
|
|
||||||
// Subscribe to the ReplaySubject
|
|
||||||
const subscription = replaySubject.subscribe({
|
|
||||||
next: (data) => {
|
|
||||||
const canPush = smartStream.push(data);
|
|
||||||
if (!canPush) {
|
|
||||||
// If push returns false, pause the subscription because of backpressure
|
|
||||||
isBackpressured = true;
|
|
||||||
subscription.unsubscribe();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: (err) => {
|
|
||||||
smartStream.emit('error', err);
|
|
||||||
},
|
|
||||||
complete: () => {
|
|
||||||
smartStream.push(null); // End the stream when the ReplaySubject completes
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Listen for 'drain' event to resume the subscription if it was paused
|
|
||||||
smartStream.on('drain', () => {
|
|
||||||
if (isBackpressured) {
|
|
||||||
isBackpressured = false;
|
|
||||||
// Resubscribe to the ReplaySubject since we previously paused
|
|
||||||
smartStream.observableSubscription = replaySubject.subscribe({
|
|
||||||
next: (data) => {
|
|
||||||
if (!smartStream.push(data)) {
|
|
||||||
smartStream.observableSubscription?.unsubscribe();
|
|
||||||
isBackpressured = true;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// No need to repeat error and complete handling here because it's already set up above
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return smartStream;
|
|
||||||
}
|
|
||||||
|
|
||||||
// INSTANCE
|
// INSTANCE
|
||||||
private readFunction?: () => Promise<void>;
|
private backpressuredArray: plugins.lik.BackpressuredArray<TOutput>;
|
||||||
private handleBackpressure: boolean;
|
public options: ISmartDuplexOptions<TInput, TOutput>;
|
||||||
private writeFunction?: IStreamWriteFunction<TInput, TOutput>;
|
|
||||||
private finalFunction?: IStreamFinalFunction<TOutput>;
|
|
||||||
private observableSubscription?: plugins.smartrx.rxjs.Subscription;
|
private observableSubscription?: plugins.smartrx.rxjs.Subscription;
|
||||||
|
private debugLog(messageArg: string) {
|
||||||
|
if (this.options.debug) {
|
||||||
|
console.log(messageArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
constructor(optionsArg?: ISmartDuplexOptions<TInput, TOutput>) {
|
constructor(optionsArg?: ISmartDuplexOptions<TInput, TOutput>) {
|
||||||
super(optionsArg);
|
super(Object.assign({
|
||||||
this.readFunction = optionsArg?.readFunction;
|
highWaterMark: 1,
|
||||||
this.writeFunction = optionsArg?.writeFunction;
|
}, optionsArg));
|
||||||
this.finalFunction = optionsArg?.finalFunction;
|
this.options = optionsArg;
|
||||||
this.handleBackpressure = optionsArg?.handleBackpressure ?? true;
|
this.backpressuredArray = new plugins.lik.BackpressuredArray<TOutput>(this.options.highWaterMark || 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async _read(size: number): Promise<void> {
|
public async _read(size: number): Promise<void> {
|
||||||
if (this.readFunction) {
|
this.debugLog(`${this.options.name}: read was called`);
|
||||||
await this.readFunction();
|
await this.backpressuredArray.waitForItems();
|
||||||
|
this.debugLog(`${this.options.name}: successfully waited for items.`);
|
||||||
|
if (this.options.readFunction) {
|
||||||
|
await this.options.readFunction();
|
||||||
|
}
|
||||||
|
let canPushMore = true;
|
||||||
|
while(this.backpressuredArray.data.length > 0 && canPushMore) {
|
||||||
|
const nextChunk = this.backpressuredArray.shift();
|
||||||
|
canPushMore = this.push(nextChunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public push(chunkArg?: TOutput | null): boolean {
|
private asyncWritePromiseObjectmap = new plugins.lik.ObjectMap<Promise<any>>();
|
||||||
const result = super.push(chunkArg);
|
|
||||||
if (!result && this.handleBackpressure) {
|
|
||||||
this.pause();
|
|
||||||
// Listen for 'drain' event to resume
|
|
||||||
this.once('drain', () => {
|
|
||||||
this.resume(); // Resume the source of data
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the _write method types the chunk as TInput and encodes TOutput
|
// Ensure the _write method types the chunk as TInput and encodes TOutput
|
||||||
public async _write(chunk: TInput, encoding: string, callback: (error?: Error | null) => void) {
|
public async _write(chunk: TInput, encoding: string, callback: (error?: Error | null) => void) {
|
||||||
if (!this.writeFunction) {
|
if (!this.options.writeFunction) {
|
||||||
return callback(new Error('No stream function provided'));
|
return callback(new Error('No stream function provided'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isTruncated = false;
|
||||||
const tools: IStreamTools = {
|
const tools: IStreamTools = {
|
||||||
truncate: () => {
|
truncate: () => {
|
||||||
this.push(null);
|
this.push(null);
|
||||||
|
isTruncated = true;
|
||||||
callback();
|
callback();
|
||||||
},
|
},
|
||||||
push: (pushArg: TOutput) => this.push(pushArg),
|
push: async (pushArg: TOutput) => {
|
||||||
|
const canPushMore = this.backpressuredArray.push(pushArg);
|
||||||
|
if (!canPushMore) {
|
||||||
|
this.debugLog(`${this.options.name}: cannot push more`);
|
||||||
|
await this.backpressuredArray.waitForSpace();
|
||||||
|
this.debugLog(`${this.options.name}: can push more again`);
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const modifiedChunk = await this.writeFunction(chunk, tools);
|
const writeDeferred = plugins.smartpromise.defer();
|
||||||
|
this.asyncWritePromiseObjectmap.add(writeDeferred.promise);
|
||||||
|
const modifiedChunk = await this.options.writeFunction(chunk, tools);
|
||||||
|
if (isTruncated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (modifiedChunk) {
|
if (modifiedChunk) {
|
||||||
this.push(modifiedChunk);
|
await tools.push(modifiedChunk);
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
|
writeDeferred.resolve();
|
||||||
|
writeDeferred.promise.then(() => {
|
||||||
|
this.asyncWritePromiseObjectmap.remove(writeDeferred.promise);
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async _final(callback: (error?: Error | null) => void) {
|
public async _final(callback: (error?: Error | null) => void) {
|
||||||
if (this.finalFunction) {
|
await Promise.all(this.asyncWritePromiseObjectmap.getArray());
|
||||||
|
if (this.options.finalFunction) {
|
||||||
const tools: IStreamTools = {
|
const tools: IStreamTools = {
|
||||||
truncate: () => callback(),
|
truncate: () => callback(),
|
||||||
push: (pipeObject) => this.push(pipeObject),
|
push: async (pipeObject) => {
|
||||||
|
this.backpressuredArray.push(pipeObject);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const finalChunk = await this.finalFunction(tools);
|
const finalChunk = await this.options.finalFunction(tools);
|
||||||
if (finalChunk) {
|
if (finalChunk) {
|
||||||
this.push(finalChunk);
|
this.backpressuredArray.push(finalChunk);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
this.backpressuredArray.push(null);
|
||||||
callback(err);
|
callback(err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// nothing here
|
|
||||||
}
|
}
|
||||||
this.push(null);
|
this.backpressuredArray.push(null);
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,9 @@ import * as stream from 'stream';
|
|||||||
export { stream };
|
export { stream };
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
|
import * as lik from '@push.rocks/lik';
|
||||||
import * as smartpromise from '@push.rocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartrx from '@push.rocks/smartrx';
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
|
|
||||||
export { smartpromise, smartrx };
|
export { lik, smartpromise, smartrx };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user