@tdreyno/pretty-please
Advanced tools
Comparing version 1.5.1 to 1.6.0
@@ -163,2 +163,6 @@ 'use strict'; | ||
append(...items) { | ||
return map(a => [a, ...items], this); | ||
} | ||
tap(fn) { | ||
@@ -165,0 +169,0 @@ return tap(fn, this); |
@@ -62,2 +62,5 @@ /* eslint-disable @typescript-eslint/no-misused-promises, @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-explicit-any, @typescript-eslint/no-use-before-define */ | ||
} | ||
append(...items) { | ||
return map(a => [a, ...items], this); | ||
} | ||
tap(fn) { | ||
@@ -64,0 +67,0 @@ return tap(fn, this); |
@@ -53,2 +53,7 @@ export declare type Reject<E> = (error: E) => void; | ||
forward<S2>(value: S2): Task<E, S2>; | ||
append<A, B, C, D, E>(a: A, b: B, c: C, d: D, e: E): Task<E, [S, A, B, C, D, E]>; | ||
append<A, B, C, D>(a: A, b: B, c: C, d: D): Task<E, [S, A, B, C, D]>; | ||
append<A, B, C>(a: A, b: B, c: C): Task<E, [S, A, B, C]>; | ||
append<A, B>(a: A, b: B): Task<E, [S, A, B]>; | ||
append<A>(a: A): Task<E, [S, A]>; | ||
tap(fn: (result: S) => void): Task<E, S>; | ||
@@ -55,0 +60,0 @@ tapChain<S2>(fn: (result: S) => Task<E, S2> | Promise<S2>): Task<E, S>; |
@@ -131,2 +131,5 @@ function initialize() { | ||
} | ||
append(...items) { | ||
return map(a => [a, ...items], this); | ||
} | ||
tap(fn) { | ||
@@ -133,0 +136,0 @@ return tap(fn, this); |
@@ -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){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}; | ||
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)}append(...t){return I(n=>[n,...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.1", | ||
"version": "1.6.0", | ||
"files": [ | ||
@@ -28,3 +28,3 @@ "dist-*/", | ||
"@types/puppeteer": "^2.0.0", | ||
"@types/react": "^16.9.22", | ||
"@types/react": "^16.9.23", | ||
"@typescript-eslint/eslint-plugin": "^2.21.0", | ||
@@ -40,3 +40,3 @@ "@typescript-eslint/parser": "^2.21.0", | ||
"jest": "^25.1.0", | ||
"lint-staged": "^10.0.7", | ||
"lint-staged": "^10.0.8", | ||
"prettier": "^1.19.1", | ||
@@ -43,0 +43,0 @@ "puppeteer": "^2.1.1", |
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
304992
187
4655