@typed/maybe
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -1,3 +0,9 @@ | ||
import * as types from '@typed/core'; | ||
export declare type Just<A> = types.Just<A>; | ||
/** | ||
* A JSON-serializable Just data-structure | ||
* @name Just | ||
* @type | ||
*/ | ||
export interface Just<A> { | ||
readonly '@typed/Just': A; | ||
} | ||
export declare namespace Just { | ||
@@ -4,0 +10,0 @@ /** |
@@ -1,3 +0,4 @@ | ||
import * as types from '@typed/core'; | ||
export declare type Maybe<A> = types.Maybe<A>; | ||
import { Just } from './Just'; | ||
import { Nothing } from './Nothing'; | ||
export declare type Maybe<A> = Just<A> | Nothing; | ||
export declare namespace Maybe { | ||
@@ -4,0 +5,0 @@ /** |
@@ -1,3 +0,9 @@ | ||
import * as types from '@typed/core'; | ||
export declare type Nothing = types.Nothing; | ||
/** | ||
* The Nothing type, used in place of nulls or undefined. | ||
* @name Nothing | ||
* @type | ||
*/ | ||
export interface Nothing { | ||
readonly '@typed/Nothing': true; | ||
} | ||
export declare const Nothing: Nothing; |
@@ -1,3 +0,9 @@ | ||
import * as types from '@typed/core'; | ||
export declare type Just<A> = types.Just<A>; | ||
/** | ||
* A JSON-serializable Just data-structure | ||
* @name Just | ||
* @type | ||
*/ | ||
export interface Just<A> { | ||
readonly '@typed/Just': A; | ||
} | ||
export declare namespace Just { | ||
@@ -4,0 +10,0 @@ /** |
@@ -1,3 +0,4 @@ | ||
import * as types from '@typed/core'; | ||
export declare type Maybe<A> = types.Maybe<A>; | ||
import { Just } from './Just'; | ||
import { Nothing } from './Nothing'; | ||
export declare type Maybe<A> = Just<A> | Nothing; | ||
export declare namespace Maybe { | ||
@@ -4,0 +5,0 @@ /** |
@@ -1,3 +0,9 @@ | ||
import * as types from '@typed/core'; | ||
export declare type Nothing = types.Nothing; | ||
/** | ||
* The Nothing type, used in place of nulls or undefined. | ||
* @name Nothing | ||
* @type | ||
*/ | ||
export interface Nothing { | ||
readonly '@typed/Nothing': true; | ||
} | ||
export declare const Nothing: Nothing; |
{ | ||
"name": "@typed/maybe", | ||
"version": "3.1.0", | ||
"version": "4.0.0", | ||
"description": "Well-typed Maybe data structure", | ||
@@ -19,3 +19,3 @@ "main": "lib/index.js", | ||
"@typed/core": "2.1.0", | ||
"@typed/functions": "1.1.0" | ||
"@typed/functions": "2.0.0" | ||
}, | ||
@@ -22,0 +22,0 @@ "repository": { |
126
README.md
@@ -1,2 +0,2 @@ | ||
# @typed/maybe -- 3.0.0 | ||
# @typed/maybe -- 3.1.0 | ||
@@ -127,2 +127,126 @@ Well-typed Maybe data structure | ||
#### combine\<A, B, C\>(f: (a: A, b: B) =\> C, a: Maybe\<A\>, b: Maybe\<B\>): Maybe\<C\> | ||
<p> | ||
Applies a function with the values contained in 2 `Maybes` if both are | ||
`Just`s. If either `Maybe`s are `Nothing` then `Nothing` is returned. | ||
</p> | ||
<details> | ||
<summary>See the code</summary> | ||
```typescript | ||
export const combine: Combine = curry3(__combine) | ||
export type Combine = { | ||
<A, B, C>(f: (valueA: A, valueB: B) => C, maybeA: Maybe<A>, maybeB: Maybe<B>): Maybe<C> | ||
<A, B, C>(f: (valueA: A, valueB: B) => C, maybeA: Maybe<A>): (maybeB: Maybe<B>) => Maybe<C> | ||
<A, B, C>(f: (valueA: A, valueB: B) => C): { | ||
(maybeA: Maybe<A>, maybeB: Maybe<B>): Maybe<C> | ||
(maybeA: Maybe<A>): (maybeB: Maybe<B>) => Maybe<C> | ||
} | ||
} | ||
function __combine<A, B, C>( | ||
f: (valueA: A, valueB: B) => C, | ||
maybeA: Maybe<A>, | ||
maybeB: Maybe<B> | ||
): Maybe<C> { | ||
return combineArray(f, [maybeA, maybeB]) | ||
} | ||
``` | ||
</details> | ||
<hr /> | ||
#### combineArray\<R\>(f: (...values: Array\<any\>) =\> R, maybes: ReadonlyArray\<Maybe\<any\>\>): R | ||
<p> | ||
Applies a function with all of the values contained in an array of `Maybe`s. | ||
If *any* of the `Maybe`s are `Nothing`s then `Nothing` is returned. | ||
</p> | ||
<details> | ||
<summary>See the code</summary> | ||
```typescript | ||
export const combineArray: CombineArray = curry2(__combineArray) | ||
function __combineArray<R>( | ||
f: (...values: Array<any>) => R, | ||
maybes: ReadonlyArray<Maybe<any>> | ||
): Maybe<R> { | ||
const containsNothing = maybes.some(isNothing) | ||
return containsNothing | ||
? Nothing | ||
: Just.of<R>(f(...(maybes as ReadonlyArray<Just<any>>).map(fromJust))) | ||
} | ||
export type CombineArray = { | ||
<A, B, C>(f: (valueA: A, valueB: B) => C, maybes: [Maybe<A>, Maybe<B>]): Maybe<C> | ||
<A, B, C, D>( | ||
f: (valueA: A, valueB: B, valueC: C) => D, | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>] | ||
): Maybe<D> | ||
<A, B, C, D, E>( | ||
f: (valueA: A, valueB: B, valueC: C, valueD: D) => E, | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>] | ||
): Maybe<E> | ||
<A, B, C, D, E, F>( | ||
f: (valueA: A, valueB: B, valueC: C, valueD: D, valueE: E) => F, | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>, Maybe<E>] | ||
): Maybe<F> | ||
<A, B, C, D, E, F, G>( | ||
f: (valueA: A, valueB: B, valueC: C, valueD: D, valueE: E, valueF: F) => G, | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>, Maybe<E>, Maybe<F>] | ||
): Maybe<G> | ||
<A, B, C>(f: (valueA: A, valueB: B) => C): (maybes: [Maybe<A>, Maybe<B>]) => Maybe<C> | ||
<A, B, C, D>(f: (valueA: A, valueB: B, valueC: C) => D): ( | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>] | ||
) => Maybe<D> | ||
<A, B, C, D, E>(f: (valueA: A, valueB: B, valueC: C, valueD: D) => E): ( | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>] | ||
) => Maybe<E> | ||
<A, B, C, D, E, F>(f: (valueA: A, valueB: B, valueC: C, valueD: D, valueE: E) => F): ( | ||
maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>, Maybe<E>] | ||
) => Maybe<F> | ||
<A, B, C, D, E, F, G>( | ||
f: (valueA: A, valueB: B, valueC: C, valueD: D, valueE: E, valueF: F) => G | ||
): (maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>, Maybe<E>, Maybe<F>]) => Maybe<G> | ||
(f: ArrayConstructor): { | ||
<A, B>(maybes: [Maybe<A>, Maybe<B>]): Maybe<[A, B]> | ||
<A, B, C>(maybes: [Maybe<A>, Maybe<B>, Maybe<C>]): Maybe<[A, B, C]> | ||
<A, B, C, D>(maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>]): Maybe<[A, B, C, D]> | ||
<A, B, C, D, E>(maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>, Maybe<E>]): Maybe< | ||
[A, B, C, D, E] | ||
> | ||
<A, B, C, D, E, F>(maybes: [Maybe<A>, Maybe<B>, Maybe<C>, Maybe<D>, Maybe<E>, Maybe<F>]): Maybe< | ||
[A, B, C, D, E, F] | ||
> | ||
} | ||
<R>(f: (...values: Array<any>) => R, maybes: ReadonlyArray<Maybe<any>>): Maybe<R> | ||
<R>(f: (...values: Array<any>) => R): (maybes: ReadonlyArray<Maybe<any>>) => Maybe<R> | ||
} | ||
``` | ||
</details> | ||
<hr /> | ||
#### fromJust\<A\>(just: Just\<A\>): A | ||
@@ -129,0 +253,0 @@ |
@@ -1,5 +0,10 @@ | ||
import * as types from '@typed/core' | ||
/** | ||
* A JSON-serializable Just data-structure | ||
* @name Just | ||
* @type | ||
*/ | ||
export interface Just<A> { | ||
readonly '@typed/Just': A | ||
} | ||
export type Just<A> = types.Just<A> | ||
export namespace Just { | ||
@@ -6,0 +11,0 @@ /** |
@@ -1,6 +0,5 @@ | ||
import * as types from '@typed/core' | ||
import { Just } from './Just' | ||
import { Nothing } from './Nothing' | ||
export type Maybe<A> = types.Maybe<A> | ||
export type Maybe<A> = Just<A> | Nothing | ||
@@ -7,0 +6,0 @@ export namespace Maybe { |
@@ -1,4 +0,9 @@ | ||
import * as types from '@typed/core' | ||
export type Nothing = types.Nothing | ||
/** | ||
* The Nothing type, used in place of nulls or undefined. | ||
* @name Nothing | ||
* @type | ||
*/ | ||
export interface Nothing { | ||
readonly '@typed/Nothing': true | ||
} | ||
export const Nothing: Nothing = { '@typed/Nothing': true } |
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
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
59997
1051
423
+ Added@typed/functions@2.0.0(transitive)
- Removed@typed/functions@1.1.0(transitive)
Updated@typed/functions@2.0.0