{"id":17858480,"url":"https://github.com/google/functional-objc","last_synced_at":"2025-04-06T02:10:56.490Z","repository":{"id":56910269,"uuid":"118067864","full_name":"google/functional-objc","owner":"google","description":"Functional operators for Objective-C","archived":false,"fork":false,"pushed_at":"2023-01-11T14:23:21.000Z","size":40,"stargazers_count":348,"open_issues_count":1,"forks_count":20,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-22T00:41:42.842Z","etag":null,"topics":["functional","objective-c","operators"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-19T02:49:58.000Z","updated_at":"2025-02-08T13:20:52.000Z","dependencies_parsed_at":"2023-02-09T03:16:16.547Z","dependency_job_id":null,"html_url":"https://github.com/google/functional-objc","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Ffunctional-objc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Ffunctional-objc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Ffunctional-objc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Ffunctional-objc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/functional-objc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247423515,"owners_count":20936626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional","objective-c","operators"],"created_at":"2024-10-28T05:06:56.780Z","updated_at":"2025-04-06T02:10:56.472Z","avatar_url":"https://github.com/google.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Apache\nLicense](https://img.shields.io/github/license/google/functional-objc.svg)](LICENSE)\n[![Travis](https://img.shields.io/travis/google/promises.svg)](https://travis-ci.org/google/functional-objc)\n\n# Functional operators for Objective-C\n\nAn Objective-C library of functional operators, derived from `Swift.Sequence`,\nthat help you write more concise and readable code for collection\ntransformations. Foundation collections supported include: `NSArray`,\n`NSDictionary`, `NSOrderedSet`, and `NSSet`.\n\n## Functional Operators\n\n### Filter\n\nLoops over a collection and returns an array that contains elements that meet a\ncondition.\n\n```objectivec\nNSArray\u003cNSNumber *\u003e *filteredArray = [@[ @13, @42, @0 ] fbl_filter:^BOOL(NSNumber *value) {\n  return value.integerValue \u003e 0;\n}];\nXCTAssertEqualObjects(filteredArray, @[ @13, @42 ]);\n```\n\n### First\n\nReturns the first element in the collection that satisfies a condition.\n\n```objectivec\nNSNumber *firstValue = [@[ @13, @42, @100 ] fbl_first:^BOOL(NSNumber *value) {\n  return value.integerValue \u003e 20;\n}];\nXCTAssertEqualObjects(firstValue, @42);\n```\n\n### FlatMap\n\nSimilar to [`map`](#map), but can also flatten a collection of collections.\n\n```objectivec\nNSArray\u003cNSArray\u003cNSNumber *\u003e *\u003e *originalArray = @[ @[ @13, @42 ], @[ @14, @43 ], @[] ];\nNSArray\u003cNSNumber *\u003e *flatMappedArray = [originalArray fbl_flatMap:^id(NSArray\u003cNSNumber *\u003e *value) {\n  return value.count \u003e 0 ? value : nil;\n}];\nXCTAssertEqualObjects(flatMappedArray, @[ @13, @42, @14, @43 ]);\n```\n\n### ForEach\n\nInvokes a block on each element of the collection in the same order as a for-in\nloop.\n\n```objectivec\n[@[ @13, @42, @100 ] fbl_forEach:^(NSNumber *value) {\n  // Invokes this block for values @13, @42, @100\n}];\n```\n\n### Map\n\nLoops over a collection and applies the same operation to each element in the\ncollection.\n\n```objectivec\nNSArray\u003cNSString *\u003e *mappedArray = [@[ @13, @42, @0 ] fbl_map:^id(NSNumber *value) {\n  if (value.integerValue == 0) {\n    return nil;\n  }\n  return value.stringValue;\n}];\nXCTAssertEqualObjects(mappedArray, @[ @\"13\", @\"42\", [NSNull null] ]);\n```\n\n### Reduce\n\nCombines all items in a collection to create a single value.\n\n```objectivec\nNSNumber *reducedValue =\n    [@[ @13, @42, @100 ] fbl_reduce:@0\n                            combine:^NSNumber *(NSNumber *accumulator, NSNumber *value) {\n                              return @(accumulator.integerValue + value.integerValue);\n                            }];\nXCTAssertEqualObjects(reducedValue, @(13 + 42 + 100));\n```\n\n### Zip\n\nCreates an array of pairs built from the two input collections.\n\n```objectivec\nNSArray\u003cNSArray *\u003e *zippedArray = [@[ @13, @42, @101 ] fbl_zip:@[ @\"100\", @\"14\" ]];\nXCTAssertEqualObjects(zippedArray, @[ @[ @13, @\"100\" ], @[ @42, @\"14\" ] ]);\n```\n\n## Setup\n\n### CocoaPods\n\nAdd the following to your `Podfile`:\n\n```ruby\npod 'FunctionalObjC', '~\u003e 1.0'\n```\n\nOr, if you would also like to include the tests:\n\n```ruby\npod 'FunctionalObjC', '~\u003e 1.0', :testspecs =\u003e ['Tests']\n```\n\nThen, run `pod install`.\n\n### Carthage\n\nAdd the following to your `Cartfile`:\n\n```\ngithub \"google/functional-objc\"\n```\n\nThen, run `carthage update` and follow the [rest of instructions](https://github.com/Carthage/Carthage#getting-started).\n\n### Import\n\nImport the umbrella header as:\n\n```objectivec\n#import \u003cFBLFunctional/FBLFunctional.h\u003e\n```\n\nOr:\n\n```objectivec\n#import \"FBLFunctional.h\"\n```\n\nOr, the module:\n\n```objectivec\n@import FBLFunctional;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Ffunctional-objc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Ffunctional-objc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Ffunctional-objc/lists"}