Skip to content

Commit

Permalink
Tests for conversions, remove overloaded conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
robotlolita committed Dec 16, 2017
1 parent d27e515 commit 5f59067
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
16 changes: 0 additions & 16 deletions packages/base/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,24 +344,8 @@ declare namespace folktale {
resultToValidation<A, B>(result: Result<A, B>): Validation<A, B>
validationToMaybe<A, B>(validation: Validation<A, B>): Maybe<B>
validationToResult<A, B>(validation: Validation<A, B>): Result<A, B>


promisedToTask<V>(fn: () => Promise<V>): () => Task<any, V>
promisedToTask<V, A1>(fn: (a: A1) => Promise<V>): (a: A1) => Task<any, V>
promisedToTask<V, A1, A2>(fn: (a: A1, b: A2) => Promise<V>): (a: A1, b: A2) => Task<any, V>
promisedToTask<V, A1, A2, A3>(fn: (a: A1, b: A2, c: A3) => Promise<V>): (a: A1, b: A2, c: A3) => Task<any, V>
promisedToTask<V, A1, A2, A3, A4>(fn: (a: A1, b: A2, c: A3, d: A4) => Promise<V>): (a: A1, b: A2, c: A3, d: A4) => Task<any, V>
promisedToTask<V, A1, A2, A3, A4, A5>(fn: (a: A1, b: A2, c: A3, d: A4, e: A5) => Promise<V>): (a: A1, b: A2, c: A3, d: A4, e: A5) => Task<any, V>
promisedToTask<V, A1, A2, A3, A4, A5, A6>(fn: (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6) => Promise<V>): (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6) => Task<any, V>

nodebackToTask<E, V>(fn: (cb: (error: E, value: V) => void) => void): () => Task<E, V>
nodebackToTask<E, V, A1>(fn: (a: A1, cb: (error: E, value: V) => void) => void): (a: A1) => Task<E, V>
nodebackToTask<E, V, A1, A2>(fn: (a: A1, b: A2, cb: (error: E, value: V) => void) => void): (a: A1, b: A2) => Task<E, V>
nodebackToTask<E, V, A1, A2, A3>(fn: (a: A1, b: A2, c: A3, cb: (error: E, value: V) => void) => void): (a: A1, b: A2, c: A3) => Task<E, V>
nodebackToTask<E, V, A1, A2, A3, A4>(fn: (a: A1, b: A2, c: A3, d: A4, cb: (error: E, value: V) => void) => void): (a: A1, b: A2, c: A3, d: A4) => Task<E, V>
nodebackToTask<E, V, A1, A2, A3, A4, A5>(fn: (a: A1, b: A2, c: A3, d: A4, e: A5, cb: (error: E, value: V) => void) => void): (a: A1, b: A2, c: A3, d: A4, e: A5) => Task<E, V>
nodebackToTask<E, V, A1, A2, A3, A4, A5, A6>(fn: (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6, cb: (error: E, value: V) => void) => void): (a: A1, b: A2, c: A3, d: A4, e: A5, f: A6) => Task<E, V>

nullableToMaybe<A>(value: A | null | undefined): Maybe<A>
nullableToResult<A>(value: A | null | undefined): Result<null | undefined, A>
nullableToValidation<A, B>(value: A | null | undefined, fallback: B): Validation<B, A>
Expand Down
22 changes: 22 additions & 0 deletions packages/base/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,26 @@ import { Maybe, Validation, Result, Future, Task } from './index';
const ex21: Task<{}, string> = task.of(1).map(x => x.toFixed());
const ex22: Task<string, {}> = task.rejected(1).mapRejected(x => x.toFixed());
}
//#endregion

//#region Conversions
{
const c = _.conversions;

const ex1: Promise<number> = c.futureToPromise(_.concurrency.future.of(1));
const ex2: Result<string, number> = c.maybeToResult(_.maybe.of(1), 'bar');
const ex3: Validation<string, number> = c.maybeToValidation(_.maybe.of(1), 'bar');
const ex4: Future<any, string> = c.promiseToFuture(Promise.resolve('f'));
const ex5: Maybe<string> = c.resultToMaybe(_.result.of('f'));
const ex6: Validation<{}, string> = c.resultToValidation(_.result.Ok('f'));
const ex7: Validation<number, {}> = c.resultToValidation(_.result.Error(1));
const ex8: Maybe<string> = c.validationToMaybe(_.validation.Success('f'));
const ex9: Result<{}, number> = c.validationToResult(_.validation.Success(1));
const ex10: Result<number, {}> = c.validationToResult(_.validation.Failure(1));
const ex11: () => Task<any, number> = c.promisedToTask(() => Promise.resolve(1));
const ex12: () => Task<number, string> = c.nodebackToTask((cb: (e: number, v: string) => void) => {});
const ex13: Maybe<string> = c.nullableToMaybe('2');
const ex14: Result<null | undefined, number> = c.nullableToResult(21);
const ex15: Validation<number, string> = c.nullableToValidation('f', 34);
}
//#endregion

0 comments on commit 5f59067

Please sign in to comment.