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

@tdreyno/pretty-please

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tdreyno/pretty-please - npm Package Compare versions

Comparing version 1.5.0 to 1.5.1

15

dist-node/index.js

@@ -101,16 +101,21 @@ 'use strict';

fork(reject, resolve) {
if (this.isCanceled) {
return this;
let localCancel = this.isCanceled;
const result = {
cancel: () => localCancel = true
};
if (localCancel) {
return result;
}
this.computation(err => {
if (!this.isCanceled) {
if (!localCancel) {
reject(err);
}
}, value => {
if (!this.isCanceled) {
if (!localCancel) {
resolve(value);
}
});
return this;
return result;
}

@@ -117,0 +122,0 @@

@@ -13,15 +13,19 @@ /* eslint-disable @typescript-eslint/no-misused-promises, @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-explicit-any, @typescript-eslint/no-use-before-define */

fork(reject, resolve) {
if (this.isCanceled) {
return this;
let localCancel = this.isCanceled;
const result = {
cancel: () => (localCancel = true)
};
if (localCancel) {
return result;
}
this.computation(err => {
if (!this.isCanceled) {
if (!localCancel) {
reject(err);
}
}, value => {
if (!this.isCanceled) {
if (!localCancel) {
resolve(value);
}
});
return this;
return result;
}

@@ -28,0 +32,0 @@ cancel() {

@@ -37,3 +37,5 @@ export declare type Reject<E> = (error: E) => void;

constructor(computation: Fork<E, S>);
fork(reject: Reject<E>, resolve: Resolve<S>): this;
fork(reject: Reject<E>, resolve: Resolve<S>): {
cancel: () => void;
};
cancel(): void;

@@ -128,3 +130,5 @@ /**

*/
export declare function fork<E, S>(reject: Reject<E>, resolve: Resolve<S>, task: Task<E, S>): Task<E, S>;
export declare function fork<E, S>(reject: Reject<E>, resolve: Resolve<S>, task: Task<E, S>): {
cancel: () => void;
};
/**

@@ -131,0 +135,0 @@ * Chain a task to run after a previous task has succeeded.

@@ -82,15 +82,19 @@ function initialize() {

fork(reject, resolve) {
if (this.isCanceled) {
return this;
let localCancel = this.isCanceled;
const result = {
cancel: () => (localCancel = true)
};
if (localCancel) {
return result;
}
this.computation(err => {
if (!this.isCanceled) {
if (!localCancel) {
reject(err);
}
}, value => {
if (!this.isCanceled) {
if (!localCancel) {
resolve(value);
}
});
return this;
return result;
}

@@ -97,0 +101,0 @@ cancel() {

@@ -1,1 +0,1 @@

var t=Object.freeze({__proto__:null,initialize:function(){return{type:"Initialized"}},pending:function(){return{type:"Pending"}},succeed:function(t){return{type:"Success",result:t}},fail:function(t){return{type:"Failure",error:t}},fold:function(t,n,r,e,i){switch(i.type){case"Initialized":return t();case"Pending":return n();case"Failure":return r(i.error);case"Success":return e(i.result)}}});function n(t,n=0){return Array(t-n).fill(void 0).map((t,r)=>n+r)}function r(t){return(n,r,e,i)=>e===i.length-1?t(i):n}function e(t){return()=>t}function i(t){return t}function u(t){return(n,r,e)=>{const[i,u]=t(r,e);return n[i]=u,n}}function s(t,n,r={}){return n.reduce(u(t),r)}function c(t,[n,r]){return t[n]=r,t}class o{constructor(t){this.computation=t,this.isCanceled=!1}fork(t,n){return this.isCanceled||this.computation(n=>{this.isCanceled||t(n)},t=>{this.isCanceled||n(t)}),this}cancel(){this.isCanceled=!0}then(t,n){return this.toPromise().then(t,n)}chain(t){return p(t,this)}succeedIf(t){return function(t,n){return new o((r,e)=>{const i=t();i?e(i):n.fork(r,e)})}(t,this)}onlyOnce(){return function(t){let n,r,e="initialized",i=0;const u={};function s(t,n){const r=i++;u[r]={reject:t,resolve:n}}function c(t){e="failure",r=t,Object.keys(u).forEach(n=>{u[n].reject(t),delete u[n]})}function h(t){e="success",n=t,Object.keys(u).forEach(n=>{u[n].resolve(t),delete u[n]})}return new o((i,u)=>{switch(e){case"success":u(n);break;case"failure":i(r);break;case"pending":s(i,u);break;case"initialized":e="pending",s(i,u),t.fork(c,h)}})}(this)}toPromise(){return t=this,new Promise((n,r)=>t.fork(r,n));var t}swap(){return t=this,new o((n,r)=>t.fork(t=>r(t),t=>n(t)));var t}map(t){return I(t,this)}forward(t){return I(e(t),this)}tap(t){return function(t,n){return I(n=>(t(n),n),n)}(t,this)}tapChain(t){return function(t,n){return p(n=>m(t(n)).forward(n),n)}(t,this)}mapError(t){return P(t,this)}mapBoth(t,n){return function(t,n,r){return P(t,I(n,r))}(t,n,this)}fold(t,n){return function(t,n,r){return new o((e,i)=>r.fork(n=>i(t(n)),t=>i(n(t))))}(t,n,this)}orElse(t){return function(t,n){return new o((r,e)=>n.fork(n=>m(t(n)).fork(r,e),e))}(t,this)}ap(t){return S(this,t)}wait(t){return function(t,n){return new o((r,e)=>{setTimeout(()=>n.fork(r,e),t)})}(t,this)}retryIn(t){return function(t,n){return n.orElse(()=>n.wait(t))}(t,this)}retryWithExponentialBackoff(t,r){return function(t,r,e){return n(r).reduce((n,r)=>n.retryIn(t*2**r),e)}(t,r,this)}flatten(){return j(this)}}o.fail=d,o.succeed=a,o.empty=function(){return l(void 0)},o.failIn=function(t,n){return new o(r=>setTimeout(()=>r(n),t))},o.succeedIn=function(t,n){return new o((r,e)=>setTimeout(()=>e(n),t))},o.of=a,o.all=function(t){return 0===t.length?l([]):new o((n,r)=>{let e=!1,i=t.length;const u=[];return t.map((t,s)=>m(t).fork(t=>{e||(e=!0,n(t))},t=>{e||(i-=1,u[s]=t,0===i&&r(u))}))})},o.sequence=function(t){return 0===t.length?l([]):t.reduce((t,n)=>p(t=>I(n=>[...t,n],m(n)),t),a([]))},o.firstSuccess=function(t){return 0===t.length?d([]):new o((n,r)=>{let e=!1,i=t.length;const u=[];return t.map(t=>m(t).fork(t=>{e||(i-=1,u.push(t),0===i&&n(u))},t=>{e||(e=!0,r(t))}))})},o.never=function(){return new o(()=>{})},o.fromPromise=y,o.fromLazyPromise=function(t){return w(t).chain(y)},o.race=function(t){return new o((n,r)=>{let e=!1;return t.map(t=>m(t).fork(t=>{e||(e=!0,n(t))},t=>{e||(e=!0,r(t))}))})},o.external=f,o.emitter=function(t){const n=f();return[n,(...r)=>{try{n.resolve(t(...r))}catch(t){n.reject(t)}}]},o.succeedBy=w,o.ap=S,o.map2=k,o.map3=function(t,n,r,e){return o.of(t).ap(n).ap(r).ap(e)},o.map4=function(t,n,r,e,i){return o.of(t).ap(n).ap(r).ap(e).ap(i)},o.loop=b,o.reduce=function(t,n,r){return b(({remainingItems:n,currentResult:e})=>{if(0===n.length)return l(new g(e));const[i,...u]=n,s=r.length-u.length-1;return t(e,i,s,r).map(t=>new v({remainingItems:u,currentResult:t}))},{remainingItems:r,currentResult:n})},o.zip=function(t,n){return k(t=>n=>[t,n],t,n)},o.zipWith=function(t,n,r){return k(n=>r=>t(n,r),n,r)},o.flatten=j;class h extends o{constructor(){super((t,n)=>{switch(this.t){case"error":t(this.i);case"success":n(this.u);case"pending":this.s=t,this.o=n}}),this.t="pending"}reject(t){this.i=t,this.t="error",this.s&&this.s(t)}resolve(t){this.u=t,this.t="success",this.o&&this.o(t)}}function f(){return new h}function a(t){return new o((n,r)=>r(t))}const l=a;function w(t){return new o((n,r)=>{try{r(t())}catch(t){n(t)}})}function d(t){return new o(n=>n(t))}function p(t,n){return new o((r,e)=>n.fork(r,n=>m(t(n)).fork(r,e)))}function m(t){return t instanceof Promise?y(t):t}function y(t){return t instanceof Promise?new o((n,r)=>t.then(r,n)):l(t)}class g{constructor(t){this.value=t}}class v{constructor(t){this.value=t}}function b(t,n){return new o((r,e)=>{const i=n=>{t(n).fork(t=>{r(t)},t=>{t instanceof g&&e(t.value),t instanceof v&&i(t.value)})};i(n)})}function I(t,n){return new o((r,e)=>n.fork(r,n=>e(t(n))))}function k(t,n,r){return o.of(t).ap(n).ap(r)}function P(t,n){return new o((r,e)=>n.fork(n=>r(t(n)),e))}function S(t,n){return new o((r,e)=>{let i,u,s=!1,c=!1;const o=t=>n=>{c||(t(n),u&&s&&e(u(i)))},h=t=>{c||(c=!0,r(t))};m(t).fork(h,o(t=>{u=t})),m(n).fork(h,o(t=>{s=!0,i=t}))})}function j(t){return t.chain(i)}class z{constructor(){this.h=new Set,this.l="inactive",this.p=new Set}emit(t){return o.all(Array.from(this.h).map(n=>n(t)||o.empty()))}subscribe(t){return this.h.add(t),this.m(),()=>{this.h.delete(t),this.m()}}clear(){this.h.clear(),this.m()}onStatusChange(t){return this.p.add(t),()=>this.p.delete(t)}m(){const t=this.h.size>0?"active":"inactive";t!==this.l&&(this.l=t,Array.from(this.p).map(n=>n(t)))}}export{h as ExternalTask,g as LoopBreak,v as LoopContinue,t as RemoteData,z as Subscription,o as Task,e as constant,i as identity,s as mapToIndexedObject,c as pairsToIndexedObject,n as range,r as to,u as toIndexedObject};
var t=Object.freeze({__proto__:null,initialize:function(){return{type:"Initialized"}},pending:function(){return{type:"Pending"}},succeed:function(t){return{type:"Success",result:t}},fail:function(t){return{type:"Failure",error:t}},fold:function(t,n,r,e,i){switch(i.type){case"Initialized":return t();case"Pending":return n();case"Failure":return r(i.error);case"Success":return e(i.result)}}});function n(t,n=0){return Array(t-n).fill(void 0).map((t,r)=>n+r)}function r(t){return(n,r,e,i)=>e===i.length-1?t(i):n}function e(t){return()=>t}function i(t){return t}function u(t){return(n,r,e)=>{const[i,u]=t(r,e);return n[i]=u,n}}function s(t,n,r={}){return n.reduce(u(t),r)}function c(t,[n,r]){return t[n]=r,t}class o{constructor(t){this.computation=t,this.isCanceled=!1}fork(t,n){let r=this.isCanceled;const e={cancel:()=>r=!0};return r||this.computation(n=>{r||t(n)},t=>{r||n(t)}),e}cancel(){this.isCanceled=!0}then(t,n){return this.toPromise().then(t,n)}chain(t){return p(t,this)}succeedIf(t){return function(t,n){return new o((r,e)=>{const i=t();i?e(i):n.fork(r,e)})}(t,this)}onlyOnce(){return function(t){let n,r,e="initialized",i=0;const u={};function s(t,n){const r=i++;u[r]={reject:t,resolve:n}}function c(t){e="failure",r=t,Object.keys(u).forEach(n=>{u[n].reject(t),delete u[n]})}function f(t){e="success",n=t,Object.keys(u).forEach(n=>{u[n].resolve(t),delete u[n]})}return new o((i,u)=>{switch(e){case"success":u(n);break;case"failure":i(r);break;case"pending":s(i,u);break;case"initialized":e="pending",s(i,u),t.fork(c,f)}})}(this)}toPromise(){return t=this,new Promise((n,r)=>t.fork(r,n));var t}swap(){return t=this,new o((n,r)=>t.fork(t=>r(t),t=>n(t)));var t}map(t){return I(t,this)}forward(t){return I(e(t),this)}tap(t){return function(t,n){return I(n=>(t(n),n),n)}(t,this)}tapChain(t){return function(t,n){return p(n=>m(t(n)).forward(n),n)}(t,this)}mapError(t){return P(t,this)}mapBoth(t,n){return function(t,n,r){return P(t,I(n,r))}(t,n,this)}fold(t,n){return function(t,n,r){return new o((e,i)=>r.fork(n=>i(t(n)),t=>i(n(t))))}(t,n,this)}orElse(t){return function(t,n){return new o((r,e)=>n.fork(n=>m(t(n)).fork(r,e),e))}(t,this)}ap(t){return S(this,t)}wait(t){return function(t,n){return new o((r,e)=>{setTimeout(()=>n.fork(r,e),t)})}(t,this)}retryIn(t){return function(t,n){return n.orElse(()=>n.wait(t))}(t,this)}retryWithExponentialBackoff(t,r){return function(t,r,e){return n(r).reduce((n,r)=>n.retryIn(t*2**r),e)}(t,r,this)}flatten(){return j(this)}}o.fail=d,o.succeed=a,o.empty=function(){return l(void 0)},o.failIn=function(t,n){return new o(r=>setTimeout(()=>r(n),t))},o.succeedIn=function(t,n){return new o((r,e)=>setTimeout(()=>e(n),t))},o.of=a,o.all=function(t){return 0===t.length?l([]):new o((n,r)=>{let e=!1,i=t.length;const u=[];return t.map((t,s)=>m(t).fork(t=>{e||(e=!0,n(t))},t=>{e||(i-=1,u[s]=t,0===i&&r(u))}))})},o.sequence=function(t){return 0===t.length?l([]):t.reduce((t,n)=>p(t=>I(n=>[...t,n],m(n)),t),a([]))},o.firstSuccess=function(t){return 0===t.length?d([]):new o((n,r)=>{let e=!1,i=t.length;const u=[];return t.map(t=>m(t).fork(t=>{e||(i-=1,u.push(t),0===i&&n(u))},t=>{e||(e=!0,r(t))}))})},o.never=function(){return new o(()=>{})},o.fromPromise=y,o.fromLazyPromise=function(t){return w(t).chain(y)},o.race=function(t){return new o((n,r)=>{let e=!1;return t.map(t=>m(t).fork(t=>{e||(e=!0,n(t))},t=>{e||(e=!0,r(t))}))})},o.external=h,o.emitter=function(t){const n=h();return[n,(...r)=>{try{n.resolve(t(...r))}catch(t){n.reject(t)}}]},o.succeedBy=w,o.ap=S,o.map2=k,o.map3=function(t,n,r,e){return o.of(t).ap(n).ap(r).ap(e)},o.map4=function(t,n,r,e,i){return o.of(t).ap(n).ap(r).ap(e).ap(i)},o.loop=b,o.reduce=function(t,n,r){return b(({remainingItems:n,currentResult:e})=>{if(0===n.length)return l(new g(e));const[i,...u]=n,s=r.length-u.length-1;return t(e,i,s,r).map(t=>new v({remainingItems:u,currentResult:t}))},{remainingItems:r,currentResult:n})},o.zip=function(t,n){return k(t=>n=>[t,n],t,n)},o.zipWith=function(t,n,r){return k(n=>r=>t(n,r),n,r)},o.flatten=j;class f extends o{constructor(){super((t,n)=>{switch(this.t){case"error":t(this.i);case"success":n(this.u);case"pending":this.s=t,this.o=n}}),this.t="pending"}reject(t){this.i=t,this.t="error",this.s&&this.s(t)}resolve(t){this.u=t,this.t="success",this.o&&this.o(t)}}function h(){return new f}function a(t){return new o((n,r)=>r(t))}const l=a;function w(t){return new o((n,r)=>{try{r(t())}catch(t){n(t)}})}function d(t){return new o(n=>n(t))}function p(t,n){return new o((r,e)=>n.fork(r,n=>m(t(n)).fork(r,e)))}function m(t){return t instanceof Promise?y(t):t}function y(t){return t instanceof Promise?new o((n,r)=>t.then(r,n)):l(t)}class g{constructor(t){this.value=t}}class v{constructor(t){this.value=t}}function b(t,n){return new o((r,e)=>{const i=n=>{t(n).fork(t=>{r(t)},t=>{t instanceof g&&e(t.value),t instanceof v&&i(t.value)})};i(n)})}function I(t,n){return new o((r,e)=>n.fork(r,n=>e(t(n))))}function k(t,n,r){return o.of(t).ap(n).ap(r)}function P(t,n){return new o((r,e)=>n.fork(n=>r(t(n)),e))}function S(t,n){return new o((r,e)=>{let i,u,s=!1,c=!1;const o=t=>n=>{c||(t(n),u&&s&&e(u(i)))},f=t=>{c||(c=!0,r(t))};m(t).fork(f,o(t=>{u=t})),m(n).fork(f,o(t=>{s=!0,i=t}))})}function j(t){return t.chain(i)}class z{constructor(){this.h=new Set,this.l="inactive",this.p=new Set}emit(t){return o.all(Array.from(this.h).map(n=>n(t)||o.empty()))}subscribe(t){return this.h.add(t),this.m(),()=>{this.h.delete(t),this.m()}}clear(){this.h.clear(),this.m()}onStatusChange(t){return this.p.add(t),()=>this.p.delete(t)}m(){const t=this.h.size>0?"active":"inactive";t!==this.l&&(this.l=t,Array.from(this.p).map(n=>n(t)))}}export{f as ExternalTask,g as LoopBreak,v as LoopContinue,t as RemoteData,z as Subscription,o as Task,e as constant,i as identity,s as mapToIndexedObject,c as pairsToIndexedObject,n as range,r as to,u as toIndexedObject};
{
"name": "@tdreyno/pretty-please",
"version": "1.5.0",
"version": "1.5.1",
"files": [

@@ -5,0 +5,0 @@ "dist-*/",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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