@sweet-monads/maybe
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -15,2 +15,3 @@ import { Monad } from "@sweet-monads/interfaces"; | ||
static merge<V1, V2, V3, V4, V5, V6, V7, V8, V9, L10, V10>(values: [Maybe<V1>, Maybe<V2>, Maybe<V3>, Maybe<V4>, Maybe<V5>, Maybe<V6>, Maybe<V7>, Maybe<V8>, Maybe<V9>, Maybe<V10>]): Maybe<[V1, V2, V3, V4, V5, V6, V7, V8, V9, V10]>; | ||
static from<T>(v: T): Maybe<T>; | ||
static none<T>(): Maybe<T>; | ||
@@ -22,4 +23,7 @@ static just<T>(v: T): Maybe<T>; | ||
isJust(): boolean; | ||
join<V>(this: Maybe<Maybe<V>>): Maybe<V>; | ||
map<V>(f: (r: T) => V): Maybe<V>; | ||
asyncMap<V>(f: (r: T) => Promise<V>): Promise<Maybe<V>>; | ||
chain<V>(f: (r: T) => Maybe<V>): Maybe<V>; | ||
asyncChain<V>(f: (r: T) => Promise<Maybe<V>>): Promise<Maybe<V>>; | ||
} |
18
index.js
@@ -13,2 +13,5 @@ const MaybeState = { | ||
} | ||
static from(v) { | ||
return this.just(v); | ||
} | ||
static none() { | ||
@@ -26,2 +29,5 @@ return new Maybe(MaybeState.None); | ||
} | ||
join() { | ||
return this.chain(x => x); | ||
} | ||
map(f) { | ||
@@ -33,2 +39,8 @@ if (this.isJust()) { | ||
} | ||
asyncMap(f) { | ||
if (this.isNone()) { | ||
return Promise.resolve(Maybe.none()); | ||
} | ||
return f(this.value).then(v => Maybe.just(v)); | ||
} | ||
chain(f) { | ||
@@ -40,2 +52,8 @@ if (this.isNone()) { | ||
} | ||
asyncChain(f) { | ||
if (this.isNone()) { | ||
return Promise.resolve(Maybe.none()); | ||
} | ||
return f(this.value); | ||
} | ||
} |
{ | ||
"name": "@sweet-monads/maybe", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@sweet-monads/interfaces": "^1.0.1" | ||
"@sweet-monads/interfaces": "^1.1.0" | ||
}, | ||
@@ -16,0 +16,0 @@ "author": "", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9205
82