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 to 1.0.1

10

dist-node/index.js

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

Object.prototype.andThen = function (fn) {
return fn(this);
};
function range(end, start = 0) {

@@ -702,7 +698,3 @@ return Array(end - start).fill(undefined).map((_, i) => start + i);

case "text":
try {
return succeed(JSON.parse(resp.data));
} catch (e) {
return fail(e);
}
return succeedBy(() => JSON.parse(resp.data));

@@ -709,0 +701,0 @@ default:

9

dist-src/HTTP/HTTP.js
import axios from "axios";
import { fail, fromPromise, succeed } from "../Task/Task";
import { fail, fromPromise, succeed, succeedBy } from "../Task/Task";
export function get(url, config) {

@@ -32,8 +32,3 @@ return fromPromise(axios.get(url, config));

case "text":
try {
return succeed(JSON.parse(resp.data));
}
catch (e) {
return fail(e);
}
return succeedBy(() => JSON.parse(resp.data));
default:

@@ -40,0 +35,0 @@ return fail(new Error("Invalid data"));

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

import "./extend";
import HTTP from "./HTTP/index";

@@ -3,0 +2,0 @@ import RemoteData from "./RemoteData/index";

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

import "./extend";
import HTTP from "./HTTP/index";

@@ -3,0 +2,0 @@ import RemoteData from "./RemoteData/index";

import axios from 'axios';
Object.prototype.andThen = function (fn) {
return fn(this);
};
function range(end, start = 0) {

@@ -607,8 +603,3 @@ return Array(end - start)

case "text":
try {
return succeed(JSON.parse(resp.data));
}
catch (e) {
return fail(e);
}
return succeedBy(() => JSON.parse(resp.data));
default:

@@ -615,0 +606,0 @@ return fail(new Error("Invalid data"));

@@ -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;Task.ap=ap;Task.map2=map2;Task.map3=map3;Task.map4=map4;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 map2(fn,taskA,taskB){return Task.of(fn).ap(taskA).ap(taskB)}function map3(fn,taskA,taskB,taskC){return Task.of(fn).ap(taskA).ap(taskB).ap(taskC)}function map4(fn,taskA,taskB,taskC,taskD){return Task.of(fn).ap(taskA).ap(taskB).ap(taskC).ap(taskD)}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)}}var RemoteData=Object.freeze({__proto__:null,initialize:initialize,pending:pending,succeed:succeed$1,fail:fail$1,fold:fold$1});class Subscription{constructor(){this.eventSubscribers=new Set;this.status="inactive";this.statusSubscribers=new Set}emit(value){return Task.all(Array.from(this.eventSubscribers).map(sub=>sub(value)||Task.empty()))}subscribe(fn){this.eventSubscribers.add(fn);this.checkStatus();return()=>{this.eventSubscribers.delete(fn);this.checkStatus()}}clear(){this.eventSubscribers.clear();this.checkStatus()}onStatusChange(fn){this.statusSubscribers.add(fn);return()=>this.statusSubscribers.delete(fn)}checkStatus(){const newstatus=this.eventSubscribers.size>0?"active":"inactive";if(newstatus===this.status){return}this.status=newstatus;Array.from(this.statusSubscribers).map(sub=>sub(newstatus))}}export{EndOfSequence,ExternalTask,HTTP,RemoteData,Subscription,Task,range,to};
import axios from"axios";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;Task.ap=ap;Task.map2=map2;Task.map3=map3;Task.map4=map4;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 map2(fn,taskA,taskB){return Task.of(fn).ap(taskA).ap(taskB)}function map3(fn,taskA,taskB,taskC){return Task.of(fn).ap(taskA).ap(taskB).ap(taskC)}function map4(fn,taskA,taskB,taskC,taskD){return Task.of(fn).ap(taskA).ap(taskB).ap(taskC).ap(taskD)}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":return succeedBy(()=>JSON.parse(resp.data));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)}}var RemoteData=Object.freeze({__proto__:null,initialize:initialize,pending:pending,succeed:succeed$1,fail:fail$1,fold:fold$1});class Subscription{constructor(){this.eventSubscribers=new Set;this.status="inactive";this.statusSubscribers=new Set}emit(value){return Task.all(Array.from(this.eventSubscribers).map(sub=>sub(value)||Task.empty()))}subscribe(fn){this.eventSubscribers.add(fn);this.checkStatus();return()=>{this.eventSubscribers.delete(fn);this.checkStatus()}}clear(){this.eventSubscribers.clear();this.checkStatus()}onStatusChange(fn){this.statusSubscribers.add(fn);return()=>this.statusSubscribers.delete(fn)}checkStatus(){const newstatus=this.eventSubscribers.size>0?"active":"inactive";if(newstatus===this.status){return}this.status=newstatus;Array.from(this.statusSubscribers).map(sub=>sub(newstatus))}}export{EndOfSequence,ExternalTask,HTTP,RemoteData,Subscription,Task,range,to};
{
"name": "@tdreyno/pretty-please",
"version": "1.0.0",
"version": "1.0.1",
"files": [

@@ -12,4 +12,5 @@ "dist-*/",

"dependencies": {
"axios": "^0.19.0",
"ramda": "^0.26.1",
"axios": "^0.19.0"
},
"peerDependencies": {
"react": "^16.11.0"

@@ -23,3 +24,2 @@ },

"@types/jest": "^24.0.22",
"@types/ramda": "^0.26.33",
"@types/react": "^16.9.11",

@@ -26,0 +26,0 @@ "husky": "^3.0.9",

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

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