literium-base
Advanced tools
Comparing version 0.2.3 to 0.2.4
export declare function identity<Value>(_: Value): Value; | ||
export declare function dummy(): void; | ||
export declare function do_seq<S, T1, T2>(this: S, _: T1, f1: (this: S, _: T1) => T2): T2; | ||
export declare function do_seq<S, T1, T2, T3>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3): T3; | ||
export declare function do_seq<S, T1, T2, T3, T4>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4): T4; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5): T5; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6): T6; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6, T7>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7): T7; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6, T7, T8>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7, f7: (this: S, _: T7) => T8): T8; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6, T7, T8, T9>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7, f7: (this: S, _: T7) => T8, f8: (this: S, _: T8) => T9): T9; | ||
export declare function flat_map<Arg, Res>(list: Arg[], fn: (arg: Arg, idx: number) => Res | Res[]): Res[]; | ||
export declare function flat_list<Type>(list: (Type | Type[])[]): Type[]; | ||
export declare function flat_all<Type>(...args: (Type | Type[])[]): Type[]; |
export function identity(_) { return _; } | ||
export function dummy() { } | ||
export function do_seq(_) { | ||
var fs = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
fs[_i - 1] = arguments[_i]; | ||
} | ||
for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) { | ||
var f = fs_1[_a]; | ||
_ = f.call(this, _); | ||
} | ||
return _; | ||
} | ||
export function flat_map(list, fn) { | ||
@@ -4,0 +15,0 @@ var res = []; |
@@ -27,2 +27,8 @@ import { Keyed } from './keyed'; | ||
export declare function b_ok<A, B>(res: Result<B, A>): Either<A, B>; | ||
export declare function ok_def<Value>(v: Value | void): Result<Value, void>; | ||
export declare function ok_def_or<Error>(e: Error): <Value>(v: Value | void) => Result<Value, Error>; | ||
export declare function ok_def_else<Error>(fn: () => Error): <Value>(v: Value | void) => Result<Value, Error>; | ||
export declare function err_def<Error>(e: Error | void): Result<void, Error>; | ||
export declare function err_def_or<Value>(v: Value): <Error>(e: Error | void) => Result<Value, Error>; | ||
export declare function err_def_else<Value>(fn: () => Value): <Error>(e: Error | void) => Result<Value, Error>; | ||
export declare function ok_try<Ret>(fn: () => Ret): () => Result<Ret, Error>; | ||
@@ -29,0 +35,0 @@ export declare function ok_try<Ret, Arg>(fn: (arg: Arg) => Ret): (arg: Arg) => Result<Ret, Error>; |
@@ -66,2 +66,20 @@ import { none } from './option'; | ||
} | ||
export function ok_def(v) { | ||
return v != undefined ? ok(v) : err(undefined); | ||
} | ||
export function ok_def_or(e) { | ||
return function (v) { return v != undefined ? ok(v) : err(e); }; | ||
} | ||
export function ok_def_else(fn) { | ||
return function (v) { return v != undefined ? ok(v) : err(fn()); }; | ||
} | ||
export function err_def(e) { | ||
return e != undefined ? err(e) : ok(undefined); | ||
} | ||
export function err_def_or(v) { | ||
return function (e) { return e != undefined ? err(e) : ok(v); }; | ||
} | ||
export function err_def_else(fn) { | ||
return function (e) { return e != undefined ? err(e) : ok(fn()); }; | ||
} | ||
export function ok_try(fn) { | ||
@@ -68,0 +86,0 @@ return function () { |
export declare function identity<Value>(_: Value): Value; | ||
export declare function dummy(): void; | ||
export declare function do_seq<S, T1, T2>(this: S, _: T1, f1: (this: S, _: T1) => T2): T2; | ||
export declare function do_seq<S, T1, T2, T3>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3): T3; | ||
export declare function do_seq<S, T1, T2, T3, T4>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4): T4; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5): T5; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6): T6; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6, T7>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7): T7; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6, T7, T8>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7, f7: (this: S, _: T7) => T8): T8; | ||
export declare function do_seq<S, T1, T2, T3, T4, T5, T6, T7, T8, T9>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7, f7: (this: S, _: T7) => T8, f8: (this: S, _: T8) => T9): T9; | ||
export declare function flat_map<Arg, Res>(list: Arg[], fn: (arg: Arg, idx: number) => Res | Res[]): Res[]; | ||
export declare function flat_list<Type>(list: (Type | Type[])[]): Type[]; | ||
export declare function flat_all<Type>(...args: (Type | Type[])[]): Type[]; |
@@ -7,2 +7,14 @@ "use strict"; | ||
exports.dummy = dummy; | ||
function do_seq(_) { | ||
var fs = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
fs[_i - 1] = arguments[_i]; | ||
} | ||
for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) { | ||
var f = fs_1[_a]; | ||
_ = f.call(this, _); | ||
} | ||
return _; | ||
} | ||
exports.do_seq = do_seq; | ||
function flat_map(list, fn) { | ||
@@ -9,0 +21,0 @@ var res = []; |
{ | ||
"name": "literium-base", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Core types and functions widely used by Literium web-application framework.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -27,2 +27,8 @@ import { Keyed } from './keyed'; | ||
export declare function b_ok<A, B>(res: Result<B, A>): Either<A, B>; | ||
export declare function ok_def<Value>(v: Value | void): Result<Value, void>; | ||
export declare function ok_def_or<Error>(e: Error): <Value>(v: Value | void) => Result<Value, Error>; | ||
export declare function ok_def_else<Error>(fn: () => Error): <Value>(v: Value | void) => Result<Value, Error>; | ||
export declare function err_def<Error>(e: Error | void): Result<void, Error>; | ||
export declare function err_def_or<Value>(v: Value): <Error>(e: Error | void) => Result<Value, Error>; | ||
export declare function err_def_else<Value>(fn: () => Value): <Error>(e: Error | void) => Result<Value, Error>; | ||
export declare function ok_try<Ret>(fn: () => Ret): () => Result<Ret, Error>; | ||
@@ -29,0 +35,0 @@ export declare function ok_try<Ret, Arg>(fn: (arg: Arg) => Ret): (arg: Arg) => Result<Ret, Error>; |
@@ -88,2 +88,26 @@ "use strict"; | ||
exports.b_ok = b_ok; | ||
function ok_def(v) { | ||
return v != undefined ? ok(v) : err(undefined); | ||
} | ||
exports.ok_def = ok_def; | ||
function ok_def_or(e) { | ||
return function (v) { return v != undefined ? ok(v) : err(e); }; | ||
} | ||
exports.ok_def_or = ok_def_or; | ||
function ok_def_else(fn) { | ||
return function (v) { return v != undefined ? ok(v) : err(fn()); }; | ||
} | ||
exports.ok_def_else = ok_def_else; | ||
function err_def(e) { | ||
return e != undefined ? err(e) : ok(undefined); | ||
} | ||
exports.err_def = err_def; | ||
function err_def_or(v) { | ||
return function (e) { return e != undefined ? err(e) : ok(v); }; | ||
} | ||
exports.err_def_or = err_def_or; | ||
function err_def_else(fn) { | ||
return function (e) { return e != undefined ? err(e) : ok(fn()); }; | ||
} | ||
exports.err_def_else = err_def_else; | ||
function ok_try(fn) { | ||
@@ -90,0 +114,0 @@ return function () { |
@@ -5,2 +5,17 @@ export function identity<Value>(_: Value): Value { return _; } | ||
export function do_seq<S, T1, T2>(this: S, _: T1, f1: (this: S, _: T1) => T2): T2; | ||
export function do_seq<S, T1, T2, T3>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3): T3; | ||
export function do_seq<S, T1, T2, T3, T4>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4): T4; | ||
export function do_seq<S, T1, T2, T3, T4, T5>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5): T5; | ||
export function do_seq<S, T1, T2, T3, T4, T5, T6>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6): T6; | ||
export function do_seq<S, T1, T2, T3, T4, T5, T6, T7>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7): T7; | ||
export function do_seq<S, T1, T2, T3, T4, T5, T6, T7, T8>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7, f7: (this: S, _: T7) => T8): T8; | ||
export function do_seq<S, T1, T2, T3, T4, T5, T6, T7, T8, T9>(this: S, _: T1, f1: (this: S, _: T1) => T2, f2: (this: S, _: T2) => T3, f3: (this: S, _: T3) => T4, f4: (this: S, _: T4) => T5, f5: (this: S, _: T5) => T6, f6: (this: S, _: T6) => T7, f7: (this: S, _: T7) => T8, f8: (this: S, _: T8) => T9): T9; | ||
export function do_seq<S>(this: S, _: any, ...fs: ((this: S, _: any) => any)[]): any { | ||
for (const f of fs) { | ||
_ = f.call(this, _); | ||
} | ||
return _; | ||
} | ||
export function flat_map<Arg, Res>(list: Arg[], fn: (arg: Arg, idx: number) => Res | Res[]): Res[] { | ||
@@ -7,0 +22,0 @@ const res: Res[] = []; |
@@ -93,2 +93,26 @@ import { Keyed } from './keyed'; | ||
export function ok_def<Value>(v: Value | void): Result<Value, void> { | ||
return v != undefined ? ok(v) : err(undefined); | ||
} | ||
export function ok_def_or<Error>(e: Error): <Value>(v: Value | void) => Result<Value, Error> { | ||
return <Value>(v: Value | void) => v != undefined ? ok(v) : err(e); | ||
} | ||
export function ok_def_else<Error>(fn: () => Error): <Value>(v: Value | void) => Result<Value, Error> { | ||
return <Value>(v: Value | void) => v != undefined ? ok(v) : err(fn()); | ||
} | ||
export function err_def<Error>(e: Error | void): Result<void, Error> { | ||
return e != undefined ? err(e) : ok(undefined); | ||
} | ||
export function err_def_or<Value>(v: Value): <Error>(e: Error | void) => Result<Value, Error> { | ||
return <Error>(e: Error | void) => e != undefined ? err(e) : ok(v); | ||
} | ||
export function err_def_else<Value>(fn: () => Value): <Error>(e: Error | void) => Result<Value, Error> { | ||
return <Error>(e: Error | void) => e != undefined ? err(e) : ok(fn()); | ||
} | ||
export function ok_try<Ret>(fn: () => Ret): () => Result<Ret, Error>; | ||
@@ -95,0 +119,0 @@ export function ok_try<Ret, Arg>(fn: (arg: Arg) => Ret): (arg: Arg) => Result<Ret, Error>; |
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
94348
1288