diff --git a/MogKit/MogTransformation.h b/MogKit/MogTransformation.h index 5997e3b..e8a3068 100644 --- a/MogKit/MogTransformation.h +++ b/MogKit/MogTransformation.h @@ -23,12 +23,6 @@ typedef MOGReducer *(^MOGTransformation) (MOGReducer *); */ typedef id (^MOGMapBlock) (id val); -/** - * `MOGIndexedMapBlock` is the same as `MOGMapBlock`, only it also includes the index of the value in sequence - * that is being processed. - */ -typedef id (^MOGIndexedMapBlock) (NSUInteger index, id val); - /** * `MOGPredicate` is a function that by examining the value returns YES or NO. It's typically used in `MOGFilter` or * `MOGMapDropNil`. @@ -177,19 +171,6 @@ MOGTransformation MOGReplaceWithDefault(NSDictionary *replacements, id defaultVa */ MOGTransformation MOGMapDropNil(MOGMapBlock mapBlock); -/** - * Creates a transformation that keeps values where `mapBlock` returns a non-nil value. This is similar to - * `MOGMapDropNil` with the difference that the index of the value is passed to `mapBlock` as well. - * - * @param mapBlock a function that determines if the transformation should pass on a value or not. non-nil to pass on, - * nil to drop it. - * - * @return a stateful transformation that drops all values where `mapBlock` returns nil. - * - * @see `MOGFilter`, `MOGRemove` and `MOGKeep`. - */ -MOGTransformation MOGKeepIndexed(MOGIndexedMapBlock mapBlock); - /** * Creates a transformation that drops all duplicates. Whether it's a duplicate is determined by `isEqual:` * diff --git a/MogKit/MogTransformation.m b/MogKit/MogTransformation.m index d6b12d9..8dd3656 100644 --- a/MogKit/MogTransformation.m +++ b/MogKit/MogTransformation.m @@ -132,17 +132,6 @@ MOGTransformation MOGMapDropNil(MOGMapBlock mapBlock) { return MOGCompose(MOGMap(mapBlock), MOGDropNil()); } -MOGTransformation MOGKeepIndexed(MOGIndexedMapBlock indexedMapBlock) { - return ^MOGReducer *(MOGReducer *reducer) { - __block NSUInteger index = 0; - - return [MOGReducer stepReducerWithNextReducer:reducer reduceBlock:^(id acc, id val) { - id outValue = indexedMapBlock(index++, val); - return outValue != nil ? reducer.reduce(acc, outValue) : acc; - }]; - }; -} - MOGTransformation MOGUnique(void) { return ^MOGReducer *(MOGReducer *reducer) { NSMutableSet *seenValues = [NSMutableSet new]; diff --git a/MogKitTests/MogTransformationTests.m b/MogKitTests/MogTransformationTests.m index fa04835..87a90e4 100644 --- a/MogKitTests/MogTransformationTests.m +++ b/MogKitTests/MogTransformationTests.m @@ -248,18 +248,6 @@ - (void)testKeepTransformation XCTAssertEqualObjects(expected, result); } -- (void)testKeepIndexedTransformation -{ - NSArray *array = @[@1, @2, @3, @4, @5, @6, @7, @8, @9, @10]; - NSArray *expected = @[@21, @23, @25, @27, @29]; - - NSArray *result = MOGTransform(array, MOGArrayReducer(), MOGKeepIndexed(^id(NSUInteger index, NSNumber *number) { - return index % 2 == 0 ? @(number.intValue + 20) : nil; - })); - - XCTAssertEqualObjects(expected, result); -} - - (void)testUniqueTransformation { NSArray *array = @[@1, @2, @3, @4, @3, @2, @1, @8, @9, @10]; diff --git a/README.md b/README.md index b9a229e..f3f6f92 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,6 @@ The transformation can then be reused and is not even tied to `RACStream`. - Replace - ReplaceWithDefault - MapDropNil -- KeepIndexed - Unique - Dedupe - Cat