Skip to content

Commit

Permalink
Fix stream cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Sep 9, 2023
1 parent 2fb64a9 commit ec97c19
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/seroval/src/core/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const GLOBAL_HEADER = `function ${GLOBAL_CONTEXT_PROMISE_CONSTRUCTOR}(s,f,p){ret
function $uP(p){delete p.${LOCAL_CONTEXT_PROMISE_RESOLVE};delete p.${LOCAL_CONTEXT_PROMISE_REJECT}}
function ${GLOBAL_CONTEXT_PROMISE_RESOLVE}(i,d){$R[i].${LOCAL_CONTEXT_PROMISE_RESOLVE}(d);$uP($R[i])}
function ${GLOBAL_CONTEXT_PROMISE_REJECT}(i,d){$R[i].${LOCAL_CONTEXT_PROMISE_REJECT}(d);$uP($R[i])}
function ${GLOBAL_CONTEXT_STREAM_CONSTRUCTOR}(n,e,t){function u(n,e){switch(e[0]){case 0:return n.enqueue(e[1]);case 1:return n.error(e[1]);case 2:return n.close()}}function r(t,u,r,c){for(n.push([t,u]),r=0,c=e.length;r<c;r++)e[r]([t,u])}return n=[],e=[],(t=new ReadableStream({start:function(t){!function(e,t,r){for(t=0,r=n.length;t<r;t++)u(e,n[t])}(t),e.push((function(n){u(t,n)}))}})).${LOCAL_CONTEXT_STREAM_ENQUEUE}=function(n){r(0,n)},t.${LOCAL_CONTEXT_STREAM_ERROR}=function(n){r(1,n)},t.${LOCAL_CONTEXT_STREAM_CLOSE}=function(n){r(2);delete t.${LOCAL_CONTEXT_STREAM_ENQUEUE};delete t.${LOCAL_CONTEXT_STREAM_ERROR};delete t.${LOCAL_CONTEXT_STREAM_CLOSE}},t}
function ${GLOBAL_CONTEXT_STREAM_CONSTRUCTOR}(n,e,t){function u(n,e){switch(e[0]){case 0:return n.enqueue(e[1]);case 1:return n.error(e[1]);case 2:return n.close()}}function r(t,u,r,c){for(n.push([t,u]),r=0,c=e.length;r<c;r++)e[r]([t,u])}return n=[],e=[],(t=new ReadableStream({start:function(t){!function(e,t,r){for(t=0,r=n.length;t<r;t++)u(e,n[t])}(t),e.push((function(n){u(t,n)}))}})).${LOCAL_CONTEXT_STREAM_ENQUEUE}=function(n){r(0,n)},function z(){delete t.${LOCAL_CONTEXT_STREAM_ENQUEUE};delete t.${LOCAL_CONTEXT_STREAM_ERROR};delete t.${LOCAL_CONTEXT_STREAM_CLOSE}},t.${LOCAL_CONTEXT_STREAM_ERROR}=function(n){r(1,n),z()},t.${LOCAL_CONTEXT_STREAM_CLOSE}=function(n){r(2),z()},t}
function ${GLOBAL_CONTEXT_STREAM_ENQUEUE}(i,d){$R[i].${LOCAL_CONTEXT_STREAM_ENQUEUE}(d)}
function ${GLOBAL_CONTEXT_STREAM_ERROR}(i,d){$R[i].${LOCAL_CONTEXT_STREAM_ERROR}(d)}
function ${GLOBAL_CONTEXT_STREAM_CLOSE}(i){$R[i].${LOCAL_CONTEXT_STREAM_CLOSE}()}
Expand Down
4 changes: 2 additions & 2 deletions packages/seroval/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Serializer } from './dist/esm/development/index.mjs';
const serializer = new Serializer({
globalIdentifier: '__SOLID__',
onData(value) {
console.log([value]);
console.log(value);
},
});

console.log('HEADER', [serializer.getHeader()]);
console.log(serializer.getHeader());

const source = new ReadableStream({
start(controller) {
Expand Down

0 comments on commit ec97c19

Please sign in to comment.