space-lift
Advanced tools
Comparing version 0.6.5 to 0.7.0
@@ -80,100 +80,60 @@ import { Wrapper, ArrayOps } from '../lift'; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>, t8: NullableValue<T8>, t9: NullableValue<T9>, t10: NullableValue<T10>): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>, NullableValue<T8>, NullableValue<T9>, NullableValue<T10>]): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>, t8: NullableValue<T8>, t9: NullableValue<T9>): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>, NullableValue<T8>, NullableValue<T9>]): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>, t8: NullableValue<T8>): Option<[T1, T2, T3, T4, T5, T6, T7, T8]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>, NullableValue<T8>]): Option<[T1, T2, T3, T4, T5, T6, T7, T8]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>): Option<[T1, T2, T3, T4, T5, T6, T7]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>]): Option<[T1, T2, T3, T4, T5, T6, T7]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>): Option<[T1, T2, T3, T4, T5, T6]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>]): Option<[T1, T2, T3, T4, T5, T6]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>): Option<[T1, T2, T3, T4, T5]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>]): Option<[T1, T2, T3, T4, T5]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>): Option<[T1, T2, T3, T4]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>]): Option<[T1, T2, T3, T4]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>): Option<[T1, T2, T3]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>]): Option<[T1, T2, T3]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2>(t1: NullableValue<T1>, t2: NullableValue<T2>): Option<[T1, T2]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2>(xs: [NullableValue<T1>, NullableValue<T2>]): Option<[T1, T2]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T>(...ts: Array<NullableValue<T>>): Option<T[]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T>(ts: Array<NullableValue<T>>): Option<T[]>; | ||
@@ -180,0 +140,0 @@ } |
@@ -8,9 +8,4 @@ "use strict"; | ||
}; | ||
OptionObject.all = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
OptionObject.all = function (arr) { | ||
var values = []; | ||
var arr = Array.isArray(args[0]) ? args[0] : args; | ||
for (var i = 0; i < arr.length; i++) { | ||
@@ -17,0 +12,0 @@ var value = arr[i]; |
@@ -32,80 +32,60 @@ import { Wrapper } from '../lift'; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, J, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>, h: Result<E8, H>, i: Result<E9, I>, j: Result<E10, J>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 | E10, [A, B, C, D, E, F, G, H, I, J]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, J, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>, Result<E8, H>, Result<E9, I>, Result<E10, J>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 | E10, [A, B, C, D, E, F, G, H, I, J]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, E1, E2, E3, E4, E5, E6, E7, E8, E9>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>, h: Result<E8, H>, i: Result<E9, I>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9, [A, B, C, D, E, F, G, H, I]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, E1, E2, E3, E4, E5, E6, E7, E8, E9>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>, Result<E8, H>, Result<E9, I>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9, [A, B, C, D, E, F, G, H, I]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, E1, E2, E3, E4, E5, E6, E7, E8>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>, h: Result<E8, H>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8, [A, B, C, D, E, F, G, H]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, E1, E2, E3, E4, E5, E6, E7, E8>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>, Result<E8, H>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8, [A, B, C, D, E, F, G, H]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, E1, E2, E3, E4, E5, E6, E7>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7, [A, B, C, D, E, F, G]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, E1, E2, E3, E4, E5, E6, E7>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7, [A, B, C, D, E, F, G]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, E1, E2, E3, E4, E5, E6>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>): Result<E1 | E2 | E3 | E4 | E5 | E6, [A, B, C, D, E, F]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, E1, E2, E3, E4, E5, E6>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>]): Result<E1 | E2 | E3 | E4 | E5 | E6, [A, B, C, D, E, F]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, E1, E2, E3, E4, E5>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>): Result<E1 | E2 | E3 | E4 | E5, [A, B, C, D, E]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, E1, E2, E3, E4, E5>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>]): Result<E1 | E2 | E3 | E4 | E5, [A, B, C, D, E]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E1, E2, E3, E4>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>): Result<E1 | E2 | E3 | E4, [A, B, C, D]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E1, E2, E3, E4>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>]): Result<E1 | E2 | E3 | E4, [A, B, C, D]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, E1, E2, E3>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>): Result<E1 | E2 | E3, [A, B, C]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, E1, E2, E3>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>]): Result<E1 | E2 | E3, [A, B, C]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, E1, E2>(a: Result<E1, A>, b: Result<E2, B>): Result<E1 | E2, [A, B]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, E1, E2>(xs: [Result<E1, A>, Result<E2, B>]): Result<E1 | E2, [A, B]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, E>(...results: Result<E, A>[]): Result<E, A[]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, E>(results: Result<E, A>[]): Result<E, A[]>; | ||
@@ -112,0 +92,0 @@ } |
@@ -5,9 +5,4 @@ "use strict"; | ||
var ResultObject = {}; | ||
ResultObject.all = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
ResultObject.all = function (arr) { | ||
var okValues = []; | ||
var arr = Array.isArray(args[0]) ? args[0] : args; | ||
var currentResult; | ||
@@ -14,0 +9,0 @@ for (var i = 0; i < arr.length; i++) { |
@@ -80,100 +80,60 @@ import { Wrapper, ArrayOps } from '../lift'; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>, t8: NullableValue<T8>, t9: NullableValue<T9>, t10: NullableValue<T10>): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>, NullableValue<T8>, NullableValue<T9>, NullableValue<T10>]): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>, t8: NullableValue<T8>, t9: NullableValue<T9>): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>, NullableValue<T8>, NullableValue<T9>]): Option<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>, t8: NullableValue<T8>): Option<[T1, T2, T3, T4, T5, T6, T7, T8]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7, T8>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>, NullableValue<T8>]): Option<[T1, T2, T3, T4, T5, T6, T7, T8]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>, t7: NullableValue<T7>): Option<[T1, T2, T3, T4, T5, T6, T7]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6, T7>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>, NullableValue<T7>]): Option<[T1, T2, T3, T4, T5, T6, T7]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>, t6: NullableValue<T6>): Option<[T1, T2, T3, T4, T5, T6]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5, T6>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>, NullableValue<T6>]): Option<[T1, T2, T3, T4, T5, T6]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>, t5: NullableValue<T5>): Option<[T1, T2, T3, T4, T5]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4, T5>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>, NullableValue<T5>]): Option<[T1, T2, T3, T4, T5]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>, t4: NullableValue<T4>): Option<[T1, T2, T3, T4]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3, T4>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>, NullableValue<T4>]): Option<[T1, T2, T3, T4]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3>(t1: NullableValue<T1>, t2: NullableValue<T2>, t3: NullableValue<T3>): Option<[T1, T2, T3]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2, T3>(xs: [NullableValue<T1>, NullableValue<T2>, NullableValue<T3>]): Option<[T1, T2, T3]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2>(t1: NullableValue<T1>, t2: NullableValue<T2>): Option<[T1, T2]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T1, T2>(xs: [NullableValue<T1>, NullableValue<T2>]): Option<[T1, T2]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* Creates a new Option holding the tuple of all the values contained in the passed array | ||
* if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T>(...ts: Array<NullableValue<T>>): Option<T[]>; | ||
/** | ||
* Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
* else returns None | ||
*/ | ||
all<T>(ts: Array<NullableValue<T>>): Option<T[]>; | ||
@@ -180,0 +140,0 @@ } |
@@ -6,9 +6,4 @@ import lift, { getValue } from '../lift'; | ||
}; | ||
OptionObject.all = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
OptionObject.all = function (arr) { | ||
var values = []; | ||
var arr = Array.isArray(args[0]) ? args[0] : args; | ||
for (var i = 0; i < arr.length; i++) { | ||
@@ -15,0 +10,0 @@ var value = arr[i]; |
@@ -32,80 +32,60 @@ import { Wrapper } from '../lift'; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, J, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>, h: Result<E8, H>, i: Result<E9, I>, j: Result<E10, J>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 | E10, [A, B, C, D, E, F, G, H, I, J]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, J, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>, Result<E8, H>, Result<E9, I>, Result<E10, J>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9 | E10, [A, B, C, D, E, F, G, H, I, J]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, E1, E2, E3, E4, E5, E6, E7, E8, E9>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>, h: Result<E8, H>, i: Result<E9, I>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9, [A, B, C, D, E, F, G, H, I]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, I, E1, E2, E3, E4, E5, E6, E7, E8, E9>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>, Result<E8, H>, Result<E9, I>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8 | E9, [A, B, C, D, E, F, G, H, I]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, E1, E2, E3, E4, E5, E6, E7, E8>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>, h: Result<E8, H>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8, [A, B, C, D, E, F, G, H]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, H, E1, E2, E3, E4, E5, E6, E7, E8>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>, Result<E8, H>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7 | E8, [A, B, C, D, E, F, G, H]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, E1, E2, E3, E4, E5, E6, E7>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>, g: Result<E7, G>): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7, [A, B, C, D, E, F, G]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, G, E1, E2, E3, E4, E5, E6, E7>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>, Result<E7, G>]): Result<E1 | E2 | E3 | E4 | E5 | E6 | E7, [A, B, C, D, E, F, G]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, E1, E2, E3, E4, E5, E6>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>, f: Result<E6, F>): Result<E1 | E2 | E3 | E4 | E5 | E6, [A, B, C, D, E, F]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, F, E1, E2, E3, E4, E5, E6>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>, Result<E6, F>]): Result<E1 | E2 | E3 | E4 | E5 | E6, [A, B, C, D, E, F]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, E1, E2, E3, E4, E5>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>, e: Result<E5, E>): Result<E1 | E2 | E3 | E4 | E5, [A, B, C, D, E]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E, E1, E2, E3, E4, E5>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>, Result<E5, E>]): Result<E1 | E2 | E3 | E4 | E5, [A, B, C, D, E]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E1, E2, E3, E4>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>, d: Result<E4, D>): Result<E1 | E2 | E3 | E4, [A, B, C, D]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, D, E1, E2, E3, E4>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>, Result<E4, D>]): Result<E1 | E2 | E3 | E4, [A, B, C, D]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, E1, E2, E3>(a: Result<E1, A>, b: Result<E2, B>, c: Result<E3, C>): Result<E1 | E2 | E3, [A, B, C]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, C, E1, E2, E3>(xs: [Result<E1, A>, Result<E2, B>, Result<E3, C>]): Result<E1 | E2 | E3, [A, B, C]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, B, E1, E2>(a: Result<E1, A>, b: Result<E2, B>): Result<E1 | E2, [A, B]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, B, E1, E2>(xs: [Result<E1, A>, Result<E2, B>]): Result<E1 | E2, [A, B]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
* Creates a new Ok Result holding the tuple of all the values contained in the passed array | ||
* if they were all Ok, | ||
* else returns the first encountered Err. | ||
*/ | ||
all<A, E>(...results: Result<E, A>[]): Result<E, A[]>; | ||
/** | ||
* Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, else returns the first encountered Err. | ||
*/ | ||
all<A, E>(results: Result<E, A>[]): Result<E, A[]>; | ||
@@ -112,0 +92,0 @@ } |
import { getValue } from '../lift'; | ||
var ResultObject = {}; | ||
ResultObject.all = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
ResultObject.all = function (arr) { | ||
var okValues = []; | ||
var arr = Array.isArray(args[0]) ? args[0] : args; | ||
var currentResult; | ||
@@ -11,0 +6,0 @@ for (var i = 0; i < arr.length; i++) { |
{ | ||
"name": "space-lift", | ||
"version": "0.6.5", | ||
"version": "0.7.0", | ||
"description": "Idiomatic TS array, object utils, Option, Result monads", | ||
@@ -5,0 +5,0 @@ |
@@ -1,3 +0,3 @@ | ||
**space-lift** | ||
"Lift your values into space for infinite possibilities" | ||
**space-lift** | ||
"Lift your values into space for infinite possibilities" | ||
@@ -9,3 +9,3 @@ ![](http://i.imgur.com/DWrI2JY.gif?noredirect) | ||
Design goals | ||
Design goals | ||
- 100% immutable, no magic, no overwhelming polymorphism or dynamic operators | ||
@@ -34,3 +34,3 @@ - Fun to use | ||
Here's everything that can be imported from `space-lift`: | ||
Here's everything that can be imported from `space-lift`: | ||
@@ -41,6 +41,6 @@ ```ts | ||
`lift` is a generic function that can wrap an Array or Object and give it extra functionalities | ||
`update`, `deepUpdate`, `DELETE` come from [immupdate](https://github.com/AlexGalays/immupdate) | ||
`Option`, `Some`, `None` are used to work with optional values | ||
`Result`, `Ok`, `Err` are used to work with computation that may fail | ||
`lift` is a generic function that can wrap an Array or Object and give it extra functionalities | ||
`update`, `deepUpdate`, `DELETE` come from [immupdate](https://github.com/AlexGalays/immupdate) | ||
`Option`, `Some`, `None` are used to work with optional values | ||
`Result`, `Ok`, `Err` are used to work with computation that may fail | ||
`range` is a factory function for Arrays of numbers | ||
@@ -54,3 +54,3 @@ `Set` is a factory function for objects acting as Sets | ||
The fastest way is to install everything in a single import (probably in your main file): | ||
The fastest way is to install everything in a single import (probably in your main file): | ||
@@ -63,3 +63,3 @@ ```ts | ||
But you can also choose exactly what to import: | ||
But you can also choose exactly what to import: | ||
@@ -76,3 +76,3 @@ ```ts | ||
<a name="examples"></a> | ||
# Examples | ||
# Examples | ||
@@ -118,5 +118,5 @@ ## Update an object inside an Array | ||
Most of the time, you will have to call `.value()` to read your value back (or `.get()` for options, although it is recommended to use `map`/`getOrElse`/etc instead) | ||
Because it's distracting to write `.value()` more than once per chain, some operators will automatically unwrap values returned from their iterators (like Promise->then). | ||
These operators are: | ||
Most of the time, you will have to call `.value()` to read your value back (or `.get()` for options, although it is recommended to use `map`/`getOrElse`/etc instead) | ||
Because it's distracting to write `.value()` more than once per chain, some operators will automatically unwrap values returned from their iterators (like Promise->then). | ||
These operators are: | ||
@@ -227,3 +227,3 @@ - `Option.map` | ||
<a name="api.option"></a> | ||
## Option | ||
## Option | ||
@@ -259,3 +259,3 @@ * [Option()](#Option()) | ||
If you already know the value is defined for sure (not nullable) or not, you can create a `Some` or `None` directly: | ||
If you already know the value is defined for sure (not nullable) or not, you can create a `Some` or `None` directly: | ||
@@ -269,16 +269,16 @@ ```ts | ||
<a name="Option.all"></a> | ||
#### Option.all(...optionsOrValues) | ||
#### Option.all([...optionsOrValues]) | ||
Creates a new Option holding the tuple of all the passed values if they were all Some or non null/undefined values, | ||
Creates a new Option holding the tuple of all the values contained in the passed array if they were all Some or non null/undefined values, | ||
else returns None | ||
```ts | ||
const some = Option.all( | ||
const some = Option.all([ | ||
Option(10), | ||
20, | ||
Option(5) | ||
) | ||
]) | ||
// some === Some([10, 20, 5]) | ||
const none = Option.all( | ||
const none = Option.all([ | ||
Option(10), | ||
@@ -288,3 +288,3 @@ None, | ||
null | ||
) | ||
]) | ||
// none === None | ||
@@ -351,3 +351,3 @@ ``` | ||
Applies the first function if this is a None, else applies the second function. | ||
Applies the first function if this is a None, else applies the second function. | ||
Note: Since this method creates 2 functions everytime it runs, don't use in tight loops; use isDefined() instead. | ||
@@ -383,3 +383,3 @@ | ||
`Some` instances return their value, whereas `None` always return `undefined`. | ||
`Some` instances return their value, whereas `None` always return `undefined`. | ||
This method never throws. | ||
@@ -395,3 +395,3 @@ | ||
Returns whether this Option has a defined value (i.e, it's a Some(value)) | ||
Returns whether this Option has a defined value (i.e, it's a Some(value)) | ||
Note: this refines the type of the Option to be a Some so it's guaranteed its value is not null/undefined. | ||
@@ -438,3 +438,3 @@ | ||
A `Result` is the result of a computation that may fail. An `Ok` represents a successful computation, while an `Err` represent the error case. | ||
A `Result` is the result of a computation that may fail. An `Ok` represents a successful computation, while an `Err` represent the error case. | ||
@@ -445,3 +445,3 @@ | ||
Here's everything that can be imported to use Results: | ||
Here's everything that can be imported to use Results: | ||
@@ -469,3 +469,3 @@ ```ts | ||
Creates a new Ok Result holding the tuple of all the passed values if they were all Ok, | ||
Creates a new Ok Result holding the tuple of all the values contained in the passed array if they were all Ok, | ||
else returns the first encountered Err. | ||
@@ -476,3 +476,3 @@ | ||
const result = Result.all( | ||
const result = Result.all([ | ||
Ok(20), | ||
@@ -482,3 +482,3 @@ Err('nooo'), | ||
Err('oops') | ||
) // Err('nooo') | ||
]) // Err('nooo') | ||
``` | ||
@@ -485,0 +485,0 @@ |
159870
4236