@ahanapediatrics/ahana-fp
Advanced tools
Comparing version 2.2.2 to 2.2.3
@@ -5,2 +5,9 @@ # Changelog | ||
### [2.2.3](https://github.com/ohana-pediatrics/ahana-fp/compare/v2.2.2...v2.2.3) (2020-05-04) | ||
### Bug Fixes | ||
* 🐛 ensure overloading types in Either are declared ([03f9ba1](https://github.com/ohana-pediatrics/ahana-fp/commit/03f9ba1fa7951d0610985aac1ad4e23298372400)) | ||
### [2.2.2](https://github.com/ohana-pediatrics/ahana-fp/compare/v2.2.1...v2.2.2) (2020-05-04) | ||
@@ -7,0 +14,0 @@ |
@@ -60,4 +60,4 @@ import { Optional } from './Optional'; | ||
*/ | ||
map<O>(lFunc: (val: L) => O, rFunc: (val: R) => Optional<O>): O; | ||
map<O>(lFunc: (val: L) => O | Optional<O>, rFunc: (val: R) => O | Optional<O>): O; | ||
map<T>(lFunc: (val: L) => T, rFunc: (val: R) => T): T; | ||
/** | ||
@@ -72,2 +72,3 @@ * Map the left-value of one type to a different value of another type. | ||
mapLeft<O>(lFunc: (val: L) => Optional<O>): Either<O, R>; | ||
mapLeft<T>(lFunc: (val: L) => T): Either<T, R>; | ||
/** | ||
@@ -82,2 +83,3 @@ * Map the right-value of one type to a different value of another type. | ||
mapRight<O>(rFunc: (val: R) => Optional<O>): Either<L, O>; | ||
mapRight<T>(rFunc: (val: R) => T): Either<L, T>; | ||
/** | ||
@@ -84,0 +86,0 @@ * Much like `{@link mapLeft}`, this converts an `Either` from one type to another. |
@@ -45,3 +45,25 @@ "use strict"; | ||
}); | ||
it('maps empty to empty', () => { | ||
chai_1.expect(Optional_1.Optional.empty() | ||
.map(x => x) | ||
.isPresent()).to.be.false; | ||
}); | ||
}); | ||
describe('#filter', () => { | ||
it('filters an Optional to the same value if the filter matches', () => { | ||
chai_1.expect(Optional_1.Optional.of(2) | ||
.filter(x => x === 2) | ||
.get()).to.equal(2); | ||
}); | ||
it('filters an Optional to empty if the filter does not match', () => { | ||
chai_1.expect(Optional_1.Optional.of(2) | ||
.filter(x => x !== 2) | ||
.isPresent()).to.be.false; | ||
}); | ||
it('filters empty to empty', () => { | ||
chai_1.expect(Optional_1.Optional.empty() | ||
.filter(x => true) | ||
.isPresent()).to.be.false; | ||
}); | ||
}); | ||
}); |
{ | ||
"name": "@ahanapediatrics/ahana-fp", | ||
"version": "2.2.2", | ||
"version": "2.2.3", | ||
"description": "FP-friendly classes for Typescript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
58567
28
1359