Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

it-pushable

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-pushable - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

2

dist/index.min.js
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.ItPushable = factory()}(typeof self !== 'undefined' ? self : this, function () {
"use strict";var ItPushable=(()=>{var w=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var P=(i,e)=>{for(var r in e)w(i,r,{get:e[r],enumerable:!0})},A=(i,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of S(e))!_.call(i,u)&&u!==r&&w(i,u,{get:()=>e[u],enumerable:!(t=M(e,u))||t.enumerable});return i};var I=i=>A(w({},"__esModule",{value:!0}),i);var q={};P(q,{AbortError:()=>m,pushable:()=>R,pushableV:()=>j});function d(){let i={};return i.promise=new Promise((e,r)=>{i.resolve=e,i.reject=r}),i}var b=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},h=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new b(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new b(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var m=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function R(i={}){return v(r=>{let t=r.shift();if(t==null)return{done:!0};if(t.error!=null)throw t.error;return{done:t.done===!0,value:t.value}},i)}function j(i={}){return v(r=>{let t,u=[];for(;!r.isEmpty()&&(t=r.shift(),t!=null);){if(t.error!=null)throw t.error;t.done===!1&&u.push(t.value)}return t==null?{done:!0}:{done:t.done===!0,value:u}},i)}function v(i,e){e=e??{};let r=e.onEnd,t=new h,u,l,c,a=d(),g=async()=>{try{let n;if(t.isEmpty()||(n=i(t)),n!=null)return n;if(c)return{done:!0}}finally{t.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=d()})}return new Promise((n,s)=>{l=p=>{l=null,t.push(p);try{n(i(t))}catch(o){s(o)}finally{t.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=d()})}return u}})},x=n=>l!=null?l(n):(t.push(n),u),z=n=>(t=new h,l!=null?l({error:n}):(t.push({error:n}),u)),E=n=>{if(c)return u;if(e?.objectMode!==!0&&n?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return x({done:!1,value:n})},y=n=>c?u:(c=!0,n!=null?z(n):x({done:!0})),L=()=>(t=new h,y(),{done:!0}),k=n=>(y(n),{done:!0});if(u={[Symbol.asyncIterator](){return this},next:g,return:L,throw:k,push:E,end:y,get readableLength(){return t.size},onEmpty:async n=>{let s=n?.signal;if(s?.throwIfAborted(),t.isEmpty())return;let p,o;s!=null&&(p=new Promise((T,N)=>{o=()=>{N(new m)},s.addEventListener("abort",o)}));try{await Promise.race([a.promise,p])}finally{o!=null&&s!=null&&s?.removeEventListener("abort",o)}}},r==null)return u;let f=u;return u={[Symbol.asyncIterator](){return this},next(){return f.next()},throw(n){return f.throw(n),r!=null&&(r(n),r=void 0),{done:!0}},return(){return f.return(),r!=null&&(r(),r=void 0),{done:!0}},push:E,end(n){return f.end(n),r!=null&&(r(n),r=void 0),u},get readableLength(){return f.readableLength}},u}return I(q);})();
"use strict";var ItPushable=(()=>{var y=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var P=(i,e)=>{for(var r in e)y(i,r,{get:e[r],enumerable:!0})},A=(i,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let u of _(e))!M.call(i,u)&&u!==r&&y(i,u,{get:()=>e[u],enumerable:!(t=S(e,u))||t.enumerable});return i};var I=i=>A(y({},"__esModule",{value:!0}),i);var T={};P(T,{AbortError:()=>b,pushable:()=>R,pushableV:()=>j});function c(){let i={};return i.promise=new Promise((e,r)=>{i.resolve=e,i.reject=r}),i}var p=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},h=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new p(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new p(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var b=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function R(i={}){return g(r=>{let t=r.shift();if(t==null)return{done:!0};if(t.error!=null)throw t.error;return{done:t.done===!0,value:t.value}},i)}function j(i={}){return g(r=>{let t,u=[];for(;!r.isEmpty()&&(t=r.shift(),t!=null);){if(t.error!=null)throw t.error;t.done===!1&&u.push(t.value)}return t==null?{done:!0}:{done:t.done===!0,value:u}},i)}function g(i,e){e=e??{};let r=e.onEnd,t=new h,u,l,f,m=c(),v=async()=>{try{return t.isEmpty()?f?{done:!0}:await new Promise((n,s)=>{l=d=>{l=null,t.push(d);try{n(i(t))}catch(o){s(o)}return u}}):i(t)}finally{t.isEmpty()&&queueMicrotask(()=>{m.resolve(),m=c()})}},x=n=>l!=null?l(n):(t.push(n),u),z=n=>(t=new h,l!=null?l({error:n}):(t.push({error:n}),u)),E=n=>{if(f)return u;if(e?.objectMode!==!0&&n?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return x({done:!1,value:n})},w=n=>f?u:(f=!0,n!=null?z(n):x({done:!0})),L=()=>(t=new h,w(),{done:!0}),k=n=>(w(n),{done:!0});if(u={[Symbol.asyncIterator](){return this},next:v,return:L,throw:k,push:E,end:w,get readableLength(){return t.size},onEmpty:async n=>{let s=n?.signal;if(s?.throwIfAborted(),t.isEmpty())return;let d,o;s!=null&&(d=new Promise((q,N)=>{o=()=>{N(new b)},s.addEventListener("abort",o)}));try{await Promise.race([m.promise,d])}finally{o!=null&&s!=null&&s?.removeEventListener("abort",o)}}},r==null)return u;let a=u;return u={[Symbol.asyncIterator](){return this},next(){return a.next()},throw(n){return a.throw(n),r!=null&&(r(n),r=void 0),{done:!0}},return(){return a.return(),r!=null&&(r(),r=void 0),{done:!0}},push:E,end(n){return a.end(n),r!=null&&(r(n),r=void 0),u},get readableLength(){return a.readableLength}},u}return I(T);})();
return ItPushable}));

@@ -114,12 +114,21 @@ /**

try {
let value;
if (!buffer.isEmpty()) {
value = getNext(buffer);
return getNext(buffer);
}
if (value != null) {
return value;
}
if (ended) {
return { done: true };
}
return await new Promise((resolve, reject) => {
onNext = (next) => {
onNext = null;
buffer.push(next);
try {
resolve(getNext(buffer));
}
catch (err) {
reject(err);
}
return pushable;
};
});
}

@@ -136,25 +145,2 @@ finally {

}
return new Promise((resolve, reject) => {
onNext = (next) => {
onNext = null;
buffer.push(next);
try {
resolve(getNext(buffer));
}
catch (err) {
reject(err);
}
finally {
if (buffer.isEmpty()) {
// settle promise in the microtask queue to give consumers a chance to
// await after calling .push
queueMicrotask(() => {
drain.resolve();
drain = deferred();
});
}
}
return pushable;
};
});
};

@@ -161,0 +147,0 @@ const bufferNext = (next) => {

{
"name": "it-pushable",
"version": "3.2.0",
"version": "3.2.1",
"description": "An iterable that you can push values into",

@@ -5,0 +5,0 @@ "author": "Alan Shaw",

@@ -215,15 +215,24 @@ /**

try {
let value: NextResult<ValueType> | undefined
if (!buffer.isEmpty()) {
value = getNext(buffer)
return getNext(buffer)
}
if (value != null) {
return value
}
if (ended) {
return { done: true }
}
return await new Promise<NextResult<ValueType>>((resolve, reject) => {
onNext = (next: Next<PushType>) => {
onNext = null
buffer.push(next)
try {
resolve(getNext(buffer))
} catch (err) {
reject(err)
}
return pushable
}
})
} finally {

@@ -239,26 +248,2 @@ if (buffer.isEmpty()) {

}
return new Promise((resolve, reject) => {
onNext = (next: Next<PushType>) => {
onNext = null
buffer.push(next)
try {
resolve(getNext(buffer))
} catch (err) {
reject(err)
} finally {
if (buffer.isEmpty()) {
// settle promise in the microtask queue to give consumers a chance to
// await after calling .push
queueMicrotask(() => {
drain.resolve()
drain = deferred()
})
}
}
return pushable
}
})
}

@@ -265,0 +250,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc