@ebflat9/fp
Advanced tools
Comparing version 1.0.15 to 1.0.16
@@ -9,3 +9,4 @@ export function createClient( | ||
async function isError(res) { | ||
if (!res.ok) throw new Error(await res.text()) | ||
if (!res.ok) | ||
throw new Error((await res.text()) || `HTTP response was not ok: ${res.status}`) | ||
return res | ||
@@ -12,0 +13,0 @@ } |
@@ -178,2 +178,6 @@ import { Maybe, Result, Try, TryAsync, IO, IOAsync } from './maybe.js' | ||
export const liftA2 = curry((fn, a1, a2) => a1.map(fn).ap(a2)) | ||
export const liftA3 = curry((fn, a1, a2, a3) => a1.map(fn).ap(a2).ap(a3)) | ||
export const liftA4 = curry((fn, a1, a2, a3, a4) => a1.map(fn).ap(a2).ap(a3).ap(a4)) | ||
export const composeAsync = (...fns) => fns.reduce(composeAsync2) | ||
@@ -180,0 +184,0 @@ export const pipeAsync = (...fns) => fns.reduceRight(composeAsync2) |
32
maybe.js
@@ -38,6 +38,6 @@ import { isFunction, compose, composeAsync } from './index.js' | ||
export class Just extends Maybe { | ||
isJust() { | ||
get isJust() { | ||
return true | ||
} | ||
isNothing() { | ||
get isNothing() { | ||
return false | ||
@@ -58,3 +58,3 @@ } | ||
ap(Ma) { | ||
return Ma.isNothing() | ||
return Ma.isNothing | ||
? Ma | ||
@@ -81,6 +81,6 @@ : isFunction(this.value) | ||
export class Nothing extends Maybe { | ||
isJust() { | ||
get isJust() { | ||
return false | ||
} | ||
isNothing() { | ||
get isNothing() { | ||
return true | ||
@@ -129,6 +129,6 @@ } | ||
export class Failure extends Result { | ||
isSuccess() { | ||
get isSuccess() { | ||
return false | ||
} | ||
isFailure() { | ||
get isFailure() { | ||
return true | ||
@@ -166,6 +166,6 @@ } | ||
export class Success extends Result { | ||
isSuccess() { | ||
get isSuccess() { | ||
return true | ||
} | ||
isFailure() { | ||
get isFailure() { | ||
return false | ||
@@ -180,3 +180,3 @@ } | ||
ap(Rs) { | ||
return Rs.isFailure() | ||
return Rs.isFailure | ||
? Rs | ||
@@ -244,5 +244,2 @@ : isFunction(this.value) | ||
} | ||
fold(fn = x => x) { | ||
return fn(this.unsafePerformIO) | ||
} | ||
map(fn) { | ||
@@ -266,4 +263,4 @@ return new IO(compose(fn, this.unsafePerformIO)) | ||
} | ||
static of(fn) { | ||
return new IO(() => fn) | ||
static of(x) { | ||
return new IO(() => x) | ||
} | ||
@@ -278,5 +275,2 @@ } | ||
} | ||
async fold(fn = async x => await x) { | ||
return await fn(this.unsafePerformIO) | ||
} | ||
async map(fn) { | ||
@@ -286,3 +280,3 @@ return new IO(composeAsync(fn, this.unsafePerformIO)) | ||
async flatMap(fn) { | ||
return this.map(fn).merge() | ||
return await this.map(fn).merge() | ||
} | ||
@@ -289,0 +283,0 @@ async merge() { |
{ | ||
"name": "@ebflat9/fp", | ||
"version": "1.0.15", | ||
"version": "1.0.16", | ||
"description": "my fp utils", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
40749
1452