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.0.0-beta.16 to 1.0.0-beta.17

12

dist-node/index.js

@@ -408,2 +408,6 @@ 'use strict';

function firstSuccess(tasks) {
if (tasks.length === 0) {
return fail([]);
}
return new Task((reject, resolve) => {

@@ -446,2 +450,6 @@ let isDone = false;

function all(tasks) {
if (tasks.length === 0) {
return of([]);
}
return new Task((reject, resolve) => {

@@ -484,2 +492,6 @@ let isDone = false;

function sequence(tasks) {
if (tasks.length === 0) {
return of([]);
}
return tasks.reduce((sum, task) => {

@@ -486,0 +498,0 @@ return andThen(list => {

@@ -24,3 +24,12 @@ import { Subscription } from "../Subscription";

});
test("should still resolve with no subscribers", () => {
const sub = new Subscription();
expect.hasAssertions();
const reject = jest.fn();
const resolve = jest.fn();
sub.emit("test").fork(reject, resolve);
expect(reject).not.toBeCalled();
expect(resolve).toBeCalledWith([]);
});
});
//# sourceMappingURL=Subscription.spec.js.map

@@ -337,2 +337,5 @@ // tslint:disable: max-classes-per-file

export function firstSuccess(tasks) {
if (tasks.length === 0) {
return fail([]);
}
return new Task((reject, resolve) => {

@@ -369,2 +372,5 @@ let isDone = false;

export function all(tasks) {
if (tasks.length === 0) {
return of([]);
}
return new Task((reject, resolve) => {

@@ -401,2 +407,5 @@ let isDone = false;

export function sequence(tasks) {
if (tasks.length === 0) {
return of([]);
}
return tasks.reduce((sum, task) => {

@@ -403,0 +412,0 @@ return andThen(list => {

@@ -346,2 +346,5 @@ import axios from 'axios';

function firstSuccess(tasks) {
if (tasks.length === 0) {
return fail([]);
}
return new Task((reject, resolve) => {

@@ -378,2 +381,5 @@ let isDone = false;

function all(tasks) {
if (tasks.length === 0) {
return of([]);
}
return new Task((reject, resolve) => {

@@ -410,2 +416,5 @@ let isDone = false;

function sequence(tasks) {
if (tasks.length === 0) {
return of([]);
}
return tasks.reduce((sum, task) => {

@@ -412,0 +421,0 @@ return andThen(list => {

2

dist-web/index.min.js

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

import axios from"axios";Object.prototype.andThen=function(fn){return fn(this)};function range(end,start=0){return Array(end-start).fill(undefined).map((_,i)=>start+i)}function to(fn){return(sum,_item,index,all)=>{const isLast=index===all.length-1;if(!isLast){return sum}return fn(all)}}const none=void 0;class Task{constructor(computation){this.fork=computation}andThen(fn){return andThen(fn,this)}succeedIf(fn){return succeedIf(fn,this)}onlyOnce(){return onlyOnce(this)}toPromise(){return toPromise(this)}swap(){return swap(this)}map(fn){return map(fn,this)}tap(fn){return tap(fn,this)}mapError(fn){return mapError(fn,this)}mapBoth(handleError,handleSuccess){return mapBoth(handleError,handleSuccess,this)}fold(handleError,handleSuccess){return fold(handleError,handleSuccess,this)}orElse(fn){return orElse(fn,this)}ap(task){return ap(this,task)}wait(ms){return wait(ms,this)}retryIn(ms){return retryIn(ms,this)}retryWithExponentialBackoff(ms,times){return retryWithExponentialBackoff(ms,times,this)}}Task.fail=fail;Task.succeed=succeed;Task.empty=empty;Task.failIn=failIn;Task.succeedIn=succeedIn;Task.of=succeed;Task.all=all;Task.sequence=sequence;Task.firstSuccess=firstSuccess;Task.never=never;Task.fromPromise=fromPromise;Task.race=race;Task.external=external;Task.emitter=emitter;Task.trySequence=trySequence;Task.none=none;Task.succeedBy=succeedBy;class ExternalTask extends Task{constructor(){super((reject,resolve)=>{switch(this.lastState){case"error":reject(this.alreadyError);case"success":resolve(this.alreadyResult);case"pending":this.computationReject=reject;this.computationResolve=resolve}});this.lastState="pending"}reject(error){this.alreadyError=error;this.lastState="error";if(this.computationReject){this.computationReject(error)}}resolve(result){this.alreadyResult=result;this.lastState="success";if(this.computationResolve){this.computationResolve(result)}}}function external(){return new ExternalTask}function emitter(fn){const task=external();return[task,(...args)=>{try{task.resolve(fn(...args))}catch(e){task.reject(e)}}]}function succeed(result){return new Task((_,resolve)=>resolve(result))}const of=succeed;function succeedBy(result){return new Task((reject,resolve)=>{try{resolve(result())}catch(e){reject(e)}})}function empty(){return of(void 0)}function succeedIn(ms,result){return new Task((_,resolve)=>setTimeout(()=>resolve(result),ms))}function fail(error){return new Task((reject,_)=>reject(error))}function failIn(ms,error){return new Task((reject,_)=>setTimeout(()=>reject(error),ms))}function never(){return new Task(()=>void 0)}function andThen(fn,task){return new Task((reject,resolve)=>task.fork(reject,b=>fn(b).fork(reject,resolve)))}function succeedIf(fn,task){return new Task((reject,resolve)=>{const result=fn();if(result){resolve(result);return}task.fork(reject,resolve)})}function onlyOnce(task){let state="initialized";let cachedResult;let cachedError;let callbackId=0;const callbacks={};function notify(reject,resolve){const id=callbackId++;callbacks[id]={reject:reject,resolve:resolve}}function triggerReject(error){state="failure";cachedError=error;Object.keys(callbacks).forEach(id=>{callbacks[id].reject(error);delete callbacks[id]})}function triggerResolve(result){state="success";cachedResult=result;Object.keys(callbacks).forEach(id=>{callbacks[id].resolve(result);delete callbacks[id]})}return new Task((reject,resolve)=>{switch(state){case"success":resolve(cachedResult);break;case"failure":reject(cachedError);break;case"pending":notify(reject,resolve);break;case"initialized":state="pending";notify(reject,resolve);task.fork(triggerReject,triggerResolve)}})}function fromPromise(maybePromise){if(maybePromise instanceof Promise){return new Task((reject,resolve)=>maybePromise.then(resolve,reject))}return of(maybePromise)}function toPromise(task){return new Promise((resolve,reject)=>task.fork(reject,resolve))}function race(tasks){return new Task((reject,resolve)=>{let done=false;return tasks.map(task=>task.fork(error=>{if(done){return}done=true;reject(error)},result=>{if(done){return}done=true;resolve(result)}))})}class EndOfSequence extends Error{constructor(){super("End of sequence")}}function trySequence(onError,tasks){const[head,...tail]=tasks;if(!head){return fail(new EndOfSequence)}return head.orElse(e=>{const shouldContinue=onError(e);if(shouldContinue===false){return fail(e)}if(shouldContinue===true){return trySequence(onError,tail)}return shouldContinue})}function firstSuccess(tasks){return new Task((reject,resolve)=>{let isDone=false;let runningTasks=tasks.length;const errors=[];return tasks.map(task=>task.fork(error=>{if(isDone){return}runningTasks-=1;errors.push(error);if(runningTasks===0){reject(errors)}},result=>{if(isDone){return}isDone=true;resolve(result)}))})}function all(tasks){return new Task((reject,resolve)=>{let isDone=false;let runningTasks=tasks.length;const results=[];return tasks.map((task,i)=>task.fork(error=>{if(isDone){return}isDone=true;reject(error)},result=>{if(isDone){return}runningTasks-=1;results[i]=result;if(runningTasks===0){resolve(results)}}))})}function sequence(tasks){return tasks.reduce((sum,task)=>{return andThen(list=>{return map(result=>[...list,result],task)},sum)},succeed([]))}function swap(task){return new Task((reject,resolve)=>task.fork(resolve,reject))}function map(fn,task){return new Task((reject,resolve)=>task.fork(reject,result=>resolve(fn(result))))}function tap(fn,task){return map(result=>{fn(result);return result},task)}function mapError(fn,task){return new Task((reject,resolve)=>task.fork(error=>reject(fn(error)),resolve))}function mapBoth(handleError,handleSuccess,task){return mapError(handleError,map(handleSuccess,task))}function fold(handleError,handleSuccess,task){return new Task((_,resolve)=>task.fork(error=>resolve(handleError(error)),result=>resolve(handleSuccess(result))))}function orElse(fn,task){return new Task((reject,resolve)=>task.fork(error=>fn(error).fork(reject,resolve),resolve))}function ap(task,appliedTask){return new Task((reject,resolve)=>{let targetResult;let applierFunction;let hasResultLoaded=false;let isRejected=false;const handleResolve=onResolve=>{return x=>{if(isRejected){return}onResolve(x);if(applierFunction&&hasResultLoaded){resolve(applierFunction(targetResult))}}};const handleReject=x=>{if(isRejected){return}isRejected=true;reject(x)};task.fork(handleReject,handleResolve(x=>{applierFunction=x}));appliedTask.fork(handleReject,handleResolve(x=>{hasResultLoaded=true;targetResult=x}))})}function wait(ms,task){return new Task((reject,resolve)=>{setTimeout(()=>task.fork(reject,resolve),ms)})}function retryIn(ms,task){return task.orElse(()=>task.wait(ms))}function retryWithExponentialBackoff(ms,times,task){return range(times).reduce((sum,i)=>sum.retryIn(ms*2**i),task)}function get(url,config){return fromPromise(axios.get(url,config))}function delete_(url,config){return fromPromise(axios.delete(url,config))}function head(url,config){return fromPromise(axios.head(url,config))}function post(url,data,config){return fromPromise(axios.post(url,data,config))}function put(url,data,config){return fromPromise(axios.put(url,data,config))}function patch(url,data,config){return fromPromise(axios.patch(url,data,config))}function toJSON(resp){const type=resp.config?resp.config.responseType:"text";switch(type){case"json":return succeed(resp.data);case"text":try{return succeed(JSON.parse(resp.data))}catch(e){return fail(e)}default:return fail(new Error("Invalid data"))}}var HTTP=Object.freeze({__proto__:null,get:get,delete_:delete_,head:head,post:post,put:put,patch:patch,toJSON:toJSON});function initialize(){return{type:"Initialized"}}function pending(){return{type:"Pending"}}function succeed$1(result){return{type:"Success",result:result}}function fail$1(error){return{type:"Failure",error:error}}function fold$1(onInitialized,onPending,onFailure,onSuccess,remote){switch(remote.type){case"Initialized":return onInitialized();case"Pending":return onPending();case"Failure":return onFailure(remote.error);case"Success":return onSuccess(remote.result)}}function fromTask(task){return task.map(succeed$1).orElse(e=>of(fail$1(e)))}var RemoteData=Object.freeze({__proto__:null,initialize:initialize,pending:pending,succeed:succeed$1,fail:fail$1,fold:fold$1,fromTask:fromTask});class Subscription{constructor(){this.subscribers=new Set}emit(value){return Task.all(Array.from(this.subscribers).map(sub=>sub(value)||Task.empty()))}subscribe(fn){this.subscribers.add(fn);return()=>this.subscribers.delete(fn)}clear(){this.subscribers.clear()}}export{EndOfSequence,ExternalTask,HTTP,RemoteData,Subscription,Task,range,to};
import axios from"axios";Object.prototype.andThen=function(fn){return fn(this)};function range(end,start=0){return Array(end-start).fill(undefined).map((_,i)=>start+i)}function to(fn){return(sum,_item,index,all)=>{const isLast=index===all.length-1;if(!isLast){return sum}return fn(all)}}const none=void 0;class Task{constructor(computation){this.fork=computation}andThen(fn){return andThen(fn,this)}succeedIf(fn){return succeedIf(fn,this)}onlyOnce(){return onlyOnce(this)}toPromise(){return toPromise(this)}swap(){return swap(this)}map(fn){return map(fn,this)}tap(fn){return tap(fn,this)}mapError(fn){return mapError(fn,this)}mapBoth(handleError,handleSuccess){return mapBoth(handleError,handleSuccess,this)}fold(handleError,handleSuccess){return fold(handleError,handleSuccess,this)}orElse(fn){return orElse(fn,this)}ap(task){return ap(this,task)}wait(ms){return wait(ms,this)}retryIn(ms){return retryIn(ms,this)}retryWithExponentialBackoff(ms,times){return retryWithExponentialBackoff(ms,times,this)}}Task.fail=fail;Task.succeed=succeed;Task.empty=empty;Task.failIn=failIn;Task.succeedIn=succeedIn;Task.of=succeed;Task.all=all;Task.sequence=sequence;Task.firstSuccess=firstSuccess;Task.never=never;Task.fromPromise=fromPromise;Task.race=race;Task.external=external;Task.emitter=emitter;Task.trySequence=trySequence;Task.none=none;Task.succeedBy=succeedBy;class ExternalTask extends Task{constructor(){super((reject,resolve)=>{switch(this.lastState){case"error":reject(this.alreadyError);case"success":resolve(this.alreadyResult);case"pending":this.computationReject=reject;this.computationResolve=resolve}});this.lastState="pending"}reject(error){this.alreadyError=error;this.lastState="error";if(this.computationReject){this.computationReject(error)}}resolve(result){this.alreadyResult=result;this.lastState="success";if(this.computationResolve){this.computationResolve(result)}}}function external(){return new ExternalTask}function emitter(fn){const task=external();return[task,(...args)=>{try{task.resolve(fn(...args))}catch(e){task.reject(e)}}]}function succeed(result){return new Task((_,resolve)=>resolve(result))}const of=succeed;function succeedBy(result){return new Task((reject,resolve)=>{try{resolve(result())}catch(e){reject(e)}})}function empty(){return of(void 0)}function succeedIn(ms,result){return new Task((_,resolve)=>setTimeout(()=>resolve(result),ms))}function fail(error){return new Task((reject,_)=>reject(error))}function failIn(ms,error){return new Task((reject,_)=>setTimeout(()=>reject(error),ms))}function never(){return new Task(()=>void 0)}function andThen(fn,task){return new Task((reject,resolve)=>task.fork(reject,b=>fn(b).fork(reject,resolve)))}function succeedIf(fn,task){return new Task((reject,resolve)=>{const result=fn();if(result){resolve(result);return}task.fork(reject,resolve)})}function onlyOnce(task){let state="initialized";let cachedResult;let cachedError;let callbackId=0;const callbacks={};function notify(reject,resolve){const id=callbackId++;callbacks[id]={reject:reject,resolve:resolve}}function triggerReject(error){state="failure";cachedError=error;Object.keys(callbacks).forEach(id=>{callbacks[id].reject(error);delete callbacks[id]})}function triggerResolve(result){state="success";cachedResult=result;Object.keys(callbacks).forEach(id=>{callbacks[id].resolve(result);delete callbacks[id]})}return new Task((reject,resolve)=>{switch(state){case"success":resolve(cachedResult);break;case"failure":reject(cachedError);break;case"pending":notify(reject,resolve);break;case"initialized":state="pending";notify(reject,resolve);task.fork(triggerReject,triggerResolve)}})}function fromPromise(maybePromise){if(maybePromise instanceof Promise){return new Task((reject,resolve)=>maybePromise.then(resolve,reject))}return of(maybePromise)}function toPromise(task){return new Promise((resolve,reject)=>task.fork(reject,resolve))}function race(tasks){return new Task((reject,resolve)=>{let done=false;return tasks.map(task=>task.fork(error=>{if(done){return}done=true;reject(error)},result=>{if(done){return}done=true;resolve(result)}))})}class EndOfSequence extends Error{constructor(){super("End of sequence")}}function trySequence(onError,tasks){const[head,...tail]=tasks;if(!head){return fail(new EndOfSequence)}return head.orElse(e=>{const shouldContinue=onError(e);if(shouldContinue===false){return fail(e)}if(shouldContinue===true){return trySequence(onError,tail)}return shouldContinue})}function firstSuccess(tasks){if(tasks.length===0){return fail([])}return new Task((reject,resolve)=>{let isDone=false;let runningTasks=tasks.length;const errors=[];return tasks.map(task=>task.fork(error=>{if(isDone){return}runningTasks-=1;errors.push(error);if(runningTasks===0){reject(errors)}},result=>{if(isDone){return}isDone=true;resolve(result)}))})}function all(tasks){if(tasks.length===0){return of([])}return new Task((reject,resolve)=>{let isDone=false;let runningTasks=tasks.length;const results=[];return tasks.map((task,i)=>task.fork(error=>{if(isDone){return}isDone=true;reject(error)},result=>{if(isDone){return}runningTasks-=1;results[i]=result;if(runningTasks===0){resolve(results)}}))})}function sequence(tasks){if(tasks.length===0){return of([])}return tasks.reduce((sum,task)=>{return andThen(list=>{return map(result=>[...list,result],task)},sum)},succeed([]))}function swap(task){return new Task((reject,resolve)=>task.fork(resolve,reject))}function map(fn,task){return new Task((reject,resolve)=>task.fork(reject,result=>resolve(fn(result))))}function tap(fn,task){return map(result=>{fn(result);return result},task)}function mapError(fn,task){return new Task((reject,resolve)=>task.fork(error=>reject(fn(error)),resolve))}function mapBoth(handleError,handleSuccess,task){return mapError(handleError,map(handleSuccess,task))}function fold(handleError,handleSuccess,task){return new Task((_,resolve)=>task.fork(error=>resolve(handleError(error)),result=>resolve(handleSuccess(result))))}function orElse(fn,task){return new Task((reject,resolve)=>task.fork(error=>fn(error).fork(reject,resolve),resolve))}function ap(task,appliedTask){return new Task((reject,resolve)=>{let targetResult;let applierFunction;let hasResultLoaded=false;let isRejected=false;const handleResolve=onResolve=>{return x=>{if(isRejected){return}onResolve(x);if(applierFunction&&hasResultLoaded){resolve(applierFunction(targetResult))}}};const handleReject=x=>{if(isRejected){return}isRejected=true;reject(x)};task.fork(handleReject,handleResolve(x=>{applierFunction=x}));appliedTask.fork(handleReject,handleResolve(x=>{hasResultLoaded=true;targetResult=x}))})}function wait(ms,task){return new Task((reject,resolve)=>{setTimeout(()=>task.fork(reject,resolve),ms)})}function retryIn(ms,task){return task.orElse(()=>task.wait(ms))}function retryWithExponentialBackoff(ms,times,task){return range(times).reduce((sum,i)=>sum.retryIn(ms*2**i),task)}function get(url,config){return fromPromise(axios.get(url,config))}function delete_(url,config){return fromPromise(axios.delete(url,config))}function head(url,config){return fromPromise(axios.head(url,config))}function post(url,data,config){return fromPromise(axios.post(url,data,config))}function put(url,data,config){return fromPromise(axios.put(url,data,config))}function patch(url,data,config){return fromPromise(axios.patch(url,data,config))}function toJSON(resp){const type=resp.config?resp.config.responseType:"text";switch(type){case"json":return succeed(resp.data);case"text":try{return succeed(JSON.parse(resp.data))}catch(e){return fail(e)}default:return fail(new Error("Invalid data"))}}var HTTP=Object.freeze({__proto__:null,get:get,delete_:delete_,head:head,post:post,put:put,patch:patch,toJSON:toJSON});function initialize(){return{type:"Initialized"}}function pending(){return{type:"Pending"}}function succeed$1(result){return{type:"Success",result:result}}function fail$1(error){return{type:"Failure",error:error}}function fold$1(onInitialized,onPending,onFailure,onSuccess,remote){switch(remote.type){case"Initialized":return onInitialized();case"Pending":return onPending();case"Failure":return onFailure(remote.error);case"Success":return onSuccess(remote.result)}}function fromTask(task){return task.map(succeed$1).orElse(e=>of(fail$1(e)))}var RemoteData=Object.freeze({__proto__:null,initialize:initialize,pending:pending,succeed:succeed$1,fail:fail$1,fold:fold$1,fromTask:fromTask});class Subscription{constructor(){this.subscribers=new Set}emit(value){return Task.all(Array.from(this.subscribers).map(sub=>sub(value)||Task.empty()))}subscribe(fn){this.subscribers.add(fn);return()=>this.subscribers.delete(fn)}clear(){this.subscribers.clear()}}export{EndOfSequence,ExternalTask,HTTP,RemoteData,Subscription,Task,range,to};
{
"name": "@tdreyno/pretty-please",
"version": "1.0.0-beta.16",
"version": "1.0.0-beta.17",
"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

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