mirrors-Dollar.swift-master
Swift 

所属分类:其他
开发工具:Swift
文件大小:45KB
下载次数:0
上传日期:2021-01-17 17:03:02
上 传 者jigoon
说明:  Dollar 是一个 Swift 库,为 Swift 编程语言提供函数式编程的助手方法,类似 Lo-Dash 或者 JavaScript 里的 Underscore
(Dollar is a Swift library that provides a functional programming assistant approach to the Swift programming language, similar to The Underscore in Lo-Dash or JavaScript)

文件列表:
Dollar.swift (0, 2021-01-14)
Dollar.swift\.hound.yml (37, 2021-01-14)
Dollar.swift\.swift-sample (223, 2021-01-14)
Dollar.swift\.swift-version (4, 2021-01-14)
Dollar.swift\.swiftlint.yml (226, 2021-01-14)
Dollar.swift\.travis.yml (77, 2021-01-14)
Dollar.swift\CODE_OF_CONDUCT.md (3218, 2021-01-14)
Dollar.swift\CONTRIBUTING.md (275, 2021-01-14)
Dollar.swift\Dollar.podspec (648, 2021-01-14)
Dollar.swift\Dollar.xcodeproj (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\Configs (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\Configs\Project.xcconfig (274, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\DollarTests_Info.plist (723, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\Dollar_Info.plist (723, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\project.pbxproj (12827, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\project.xcworkspace (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\project.xcworkspace\contents.xcworkspacedata (151, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\project.xcworkspace\xcshareddata (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\project.xcworkspace\xcshareddata\IDEWorkspaceChecks.plist (238, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcbaselines (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcbaselines\92E6686E19F09C6400BB4FB8.xcbaseline (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcbaselines\92E6686E19F09C6400BB4FB8.xcbaseline\18CD9413-8F71-45A7-8CAB-C12948969500.plist (1421, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcbaselines\92E6686E19F09C6400BB4FB8.xcbaseline\Info.plist (1105, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcschemes (0, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcschemes\Dollar.xcscheme (2938, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcschemes\DollarTests.xcscheme (1810, 2021-01-14)
Dollar.swift\Dollar.xcodeproj\xcshareddata\xcschemes\xcschememanagement.plist (241, 2021-01-14)
Dollar.swift\LICENSE (1077, 2021-01-14)
Dollar.swift\Package.swift (93, 2021-01-14)
Dollar.swift\Sources (0, 2021-01-14)
Dollar.swift\Sources\AutoBind.swift (2179, 2021-01-14)
Dollar.swift\Sources\AutoCurry.swift (2423, 2021-01-14)
Dollar.swift\Sources\Dollar.h (493, 2021-01-14)
Dollar.swift\Sources\Dollar.swift (63102, 2021-01-14)
Dollar.swift\Sources\Info.plist (921, 2021-01-14)
Dollar.swift\Tests (0, 2021-01-14)
Dollar.swift\Tests\DollarTests (0, 2021-01-14)
... ...

Dollar [![Build Status](https://travis-ci.org/ankurp/Dollar.svg)](https://travis-ci.org/ankurp/Dollar) ![CocoaPods](https://img.shields.io/cocoapods/v/Dollar.svg) [![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E***B0.svg)](https://houndci.com) =========== [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ankurp/Dollar?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Dollar is a Swift library that provides useful functional programming helper methods without extending any built in objects. It is similar to [Lo-Dash](https://lodash.com) or [Underscore.js](http://underscorejs.org) in Javascript. [Cent](https://github.com/ankurp/Cent) is a library that extends certain Swift object types using the extension feature and gives its two cents to Swift language. It is now moved into a separate repo to support `Swift Package Manager` NOTE: Starting Swift 4 `$` is no longer a valid identifier. So you get the following `error: '$' is not an identifier; use backticks to escape it` . Instead use `Dollar`. ## Contents ## - [Setup](#setup) - [Demo App](#demo-app) - [API Documentation](http://www.dollarswift.org) - [Usage](#dollar-usage) - [Array](#array) - [Dictionary](#dictionary) - [Object](#object) - [Function](#function) - [Chaining](#chaining) - [Contributing](#contributing) # Setup # ## Using [cocoapods](http://cocoapods.org/) version 0.36.x or greater Add `pod 'Dollar'` to your `Podfile` and run `pod install`. Add `use_frameworks!` to the end of the `Podfile`. Also checkout this [sample app](https://github.com/ankurp/DollarPodApp). ## Using [Swift Package Manager](https://github.com/apple/swift-package-manager) Add the following dependency `.Package(url: "https://github.com/ankurp/Dollar", majorVersion: 7, minor: 1)` to your `Package.swift` file and then run `swift build`. Requires swift version 2.2 or greater that you can install from https://swift.org ## Using `git submodule` 1. If you are using git then add Dollar as a submodule using `git submodule add https://github.com/ankurp/Dollar.git`. If not using git download the project using `git clone https://github.com/ankurp/Dollar.git` in your project folder. 2. Open the `Dollar` folder. Drag Dollar.xcodeproj, inside the Dollar folder, into the file navigator of your Xcode project. 3. In Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar. 4. In the tab bar at the top of that window, open the "Build Phases" panel. 5. Expand the "Link Binary with Libraries" group, and add Dollar.framework. 6. In your project file `import Dollar` and you can call all of the helper functions. Still stuck. Then checkout this screencast on [how to import](http://recordit.co/0gQiCSEREF) ## Support for Xcode and Swift * For Xcode 11 (Swift 5.0) use version `9.0.0` * For Xcode 10 (Swift 4.2) use version `8.0.0` * For Xcode 9 (Swift 4) use version `7.1.0` * For Xcode 8 (Swift 3) use version `6.0.0` * For Xcode 7 (Swift 2) use version `4.1.0` or `5.2.0` * For Xcode 6.3 (Swift 1.2) use version `3.0.3` * For Xcode 6.1 and 6.2 (Swift 1.1) use version `2.2.0` ## Demo Apps ## * Using [`Cocoa Pods`](https://github.com/ankurp/DollarPodApp) * Using [`Swift Package Manager`](https://github.com/ankurp/DollarSwiftPackage) * Using [`git submodule`](https://github.com/ankurp/DollarSubmoduleApp) ## Communication ## - If you **need help**, use [gitter.im](https://gitter.im/ankurp/Dollar) or post a question on [Stack Overflow](http://stackoverflow.com/questions/tagged/dollar.swift) with tag `dollar.swift`. - If you'd like to **ask a general question**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/dollar.swift). - If you **found a bug**, open an issue. - If you **have a feature request**, open an issue. - If you **want to contribute**, submit a pull request. # Dollar Usage # ## Array ## ### at - `Dollar.at` Creates an array of elements from the specified indexes, or keys, of the collection. Indexes may be specified as individual arguments or as arrays of indexes. ```swift Dollar.at(["ant", "bat", "cat", "dog", "egg"], indexes: 0, 2, 4) => ["ant", "cat", "egg"] ``` ### chunk - `Dollar.chunk` Creates an array of elements split into groups the length of size. If array cant be split evenly, the final chunk will be the remaining elements. ```swift Dollar.chunk([1, 2, 3, 4], size: 2) => [[1, 2], [3, 4]] Dollar.chunk([1, 2, 3, 4], size: 3) => [[1, 2, 3], [4]] ``` ### compact - `Dollar.compact` Creates an array with all nil values removed. ```swift Dollar.compact([3, nil, 4, 5]) => [3, 4, 5] Dollar.compact([nil, nil]) as NSObject[] => [] ``` ### contains - `Dollar.contains` Checks if a given value is present in the array. ```swift Dollar.contains([1, 2, 3, 1, 2, 3], value: 2) => true Dollar.contains([1, 2, 3, 1, 2, 3], value: 10) => false ``` ### cycle - `Dollar.cycle` Cycles through the array definetly or indefinetly passing each element into the callback function. The second parameter is to specify how many times to cycle through the array. If left out it will cycle indefinetly. ```swift Dollar.cycle([1, 2, 3], 2) { print($0) } // Prints the following 123123 ``` ### difference - `Dollar.difference` Creates an array excluding all values of the provided arrays ```swift Dollar.difference([1, 2, 3, 4, 5], [5, 2, 10]) => [1, 3, 4] ``` ### each - `Dollar.each` Passes each element in the array to the callback ```swift Dollar.each(["A", "B"]) { print("Value \($0)") } => ["A", "B"] Dollar.each(["A", "B"]) { (index, elem) in print("\(index) - \(elem)") } => ["0 - A", "1 - B"] ``` ### every - `Dollar.every` Checks if the given callback returns true value for all items in the array. ```swift Dollar.every([1, 2, 3, 4], callback: { $0 < 20 }) => true Dollar.every([1, 2, 3, 4]) { $0 == 1 } => false ``` ### factorial `Dollar.factorial` Returns factorial of integer ```swift Dollar.factorial(3) => 6 Dollar.factorial(0) => 1 ``` ### fetch - `Dollar.fetch` Get element from an array at the given index which can be negative to find elements from the end of the array. A default value can be returned if indexing out of bounds. ```swift let arr = [1, 2, 3, 4, 5, 6, 7, 8] Dollar.fetch(arr, 100) => nil Dollar.fetch(arr, 100, orElse: 42) => 42 Dollar.fetch(arr, -1) => 8 ``` ### fill - `Dollar.fill` Fills elements of array with value from start up to, but not including, end. This method mutates array. ```swift var arr = Array(count: 5, repeatedValue: 1) Dollar.fill(&arr, withElem: 42) => [42, 42, 42, 42, 42] var arr = Array(count: 5, repeatedValue: 1) Dollar.fill(&arr, withElem: 42, startIndex: 1, endIndex: 3) => [1, 42, 42, 42, 1] ``` ### find - `Dollar.find` Iterates over elements of an array and returning the first element that the callback returns true for. ```swift Dollar.find([1, 2, 3, 4], callback: { $0 == 2 }) => 2 Dollar.find([1, 2, 3, 4]) { $0 == 10 } => nil ``` ### findIndex - `Dollar.findIndex` This method is like find except that it returns the index of the first element that passes the callback check. ```swift let arr = [["age": 36], ["age": 40], ["age": 1]] let result = Dollar.findIndex(arr) { $0["age"] < 20 } result => 2 ``` ### findLastIndex - `Dollar.findLastIndex` This method is like findIndex except that it iterates over elements of the array from right to left. ```swift let arr = [["age": 36], ["age": 40], ["age": 1]] let result = Dollar.findLastIndex(arr) { $0["age"] > 30 } result => 1 ``` ### first - `Dollar.first(array: AnyObject[])` Gets the first element in the array. ```swift Dollar.first([1, 2, 3, 4]) => 1 Dollar.first([]) => nil ``` ### groupBy `Dollar.groupBy` This method returns a dictionary of values grouped by the value returned by a callback. ``` swift Dollar.groupBy([1, 2, 3, 4, 5], callback: {$0 % 2}) => [0: [2, 4], 1: [1, 3]] Dollar.groupBy(["strings", "with", "different", lengths"], callback: {$0.characters.count}) => [7: ["strings", "lengths"], 9: ["different"], 4: ["With"]] ``` ### second - `Dollar.second(array: AnyObject[])` Gets the second element in the array. ```swift Dollar.second([1, 2, 3, 4]) => 2 Dollar.second([1]) => nil Dollar.second([]) => nil ``` ### flatMap - `Dollar.flatMap` Maps a function that converts elements to a list and then concatenates them. ```swift let values = [2, 3, 4, 5, 6, 7] Dollar.flatMap(values) { [$0, $0] } => [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7] ``` ### flatMap - `Dollar.flatMap` Maps a function that converts a type to an Optional over an Optional, and then returns a single-level Optional. ```swift let url = NSURL(string: "https://apple.com/swift") Dollar.flatMap(url) { $0.lastPathComponent } => Optional("swift") ``` *Note*: This is the same behavior as Optional chaining. The code above translates to ```swift NSURL(string: "https://apple.com/swift/")?.lastPathComponent => Optional("swift") ``` ### flatten - `Dollar.flatten` Flattens a nested array of any depth. ```swift Dollar.flatten([[3], 4, 5]) as Int[] => [3, 4, 5] Dollar.flatten([[3], "Hello", 5]) as NSObject[] => [3, "Hello", 5] Dollar.flatten([[[3], 4], 5]) as Int[] => [3, 4, 5] ``` ### frequencies - `Dollar.frequencies` This method returns a dictionary of values in an array mapping to the total number of occurrences in the array. If passed a function it returns a frequency table of the results of the given function on the arrays elements. ```swift Dollar.frequencies(["a", "a", "b", "c", "a", "b"]) => ["a": 3, "b": 2, "c": 1] Dollar.frequencies([1, 2, 3, 4, 5]) { $0 % 2 == 0 } => [false: 3, true: 2] ``` ### gcd `Dollar.gcd` GCD function return greatest common denominator with number passed ```swift Dollar.gcd(3, 10) => 1 Dollar.gcd(3, 9) => 3 ``` ### indexOf - `Dollar.indexOf` Gets the index at which the first occurrence of value is found. ```swift Dollar.indexOf([1, 2, 3, 1, 2, 3], value: 2) => 1 Dollar.indexOf(["A", "B", "C"], value: "B") => 1 Dollar.indexOf([3, 4, 5], value: 5) => 2 Dollar.indexOf([3, 4, 5], value: 3) => 0 Dollar.indexOf([3, 4, 5], value: 2) => nil ``` ### initial - `Dollar.initial` Gets all but the last element or last n elements of an array. ```swift Dollar.initial([3, 4, 5]) => [3, 4] Dollar.initial([3, 4, 5], numElements: 2) => [3] ``` ### intersection - `Dollar.intersection` Creates an array of unique values present in all provided arrays. ```swift Dollar.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]) => [1, 2] ``` ### it-isIn `Dollar.it(i: T, isIn range: Range)` Returns true if i is in interval or range ```swift Dollar.it("c", isIn: "a"..."z") => true Dollar.it("z", isIn: "a"..<"z") => false Dollar.it(1, isIn: -1.0...10.0) => true ``` ### last - `Dollar.last` Gets the last element from the array. ```swift Dollar.last([3, 4, 5]) => 5 ``` ### lastIndexOf - `Dollar.lastIndexOf` Gets the index at which the last occurrence of value is found. ```swift Dollar.lastIndexOf([1, 2, 3, 1, 2, 3], value: 2) => 4 ``` ### lcm `Dollar.lcm` LCM method return least common multiple with number passed ```swift Dollar.lcm(3, 10) => 30 Dollar.lcm(3, 9) => 9 ``` ### rest - `Dollar.rest` The opposite of initial this method gets all but the first element or first n elements of an array. ```swift Dollar.rest([3, 4, 5]) => [4, 5] Dollar.rest([3, 4, 5], numElements: 2) => [5] ``` ### map - `Dollar.map` Maps each element to new value based on the map function passed ```swift Dollar.map([1, 2, 3, 4]) { $0 * 2 } => [2, 4, 6, 8] ``` ### min - `Dollar.min` Retrieves the minimum value in an array. ```swift Dollar.min([2, 1, 2, 3, 4]) => 1 ``` ### max - `Dollar.max` Retrieves the maximum value in an array. ```swift Dollar.max([1, 2, 3, 4, 2, 1]) => 4 ``` ### pluck - `Dollar.pluck` Retrieves the value of a specified property from all elements in the array. ```swift let arr = [["age": 20], ["age": 30], ["age": 40]] Dollar.pluck(arr, value: "age") => [20, 30, 40] ``` ### pull - `Dollar.pull` Removes all provided values from the given array. ```swift Dollar.pull([3, 4, 5, 3, 5], values: 3, 5) => [4] Dollar.pull([3, 4, 5, 3, 5], values: 4) => [3, 5, 3, 5] Dollar.pull([3, 4, 5, 3, 5], values: 3, 4, 5) => [] ``` ### pullAt - `Dollar.pullAt` Removes all provided values from the given array at the given indices ```swift let arr = [10, 20, 30, 40, 50] Dollar.pullAt(arr, indices: 1, 2, 3) ``` ### range - `Dollar.range` Creates an array of numbers (positive and/or negative) progressing from start up to but not including end. ```swift Dollar.range(4) => [0, 1, 2, 3] Dollar.range(from: 1, to: 5) => [1, 2, 3, 4] Dollar.range(from: 0, to: 20, incrementBy: 5) => [0, 5, 10, 15] Dollar.range(from: 1, through: 5) => [1, 2, 3, 4, 5] Dollar.range(from: 0, through: 20, incrementBy: 5) => [0, 5, 10, 15, 20] ``` ### reduce - `Dollar.reduce` Reduce function that will resolve to one value after performing combine function on all elements ```swift Dollar.reduce([1, 2, 3], initial: 0) { (total, element) in total + element } => 6 ``` ### sample - `Dollar.sample` Returns a sample item from the array ```swift let arr : Int[] = [2, 1, 2, 3, 4] Dollar.contains(arr, value: Dollar.sample(arr)) => true ``` ### sequence - `Dollar.sequence` Creates an array of an arbitrary sequence. Especially useful with builtin ranges. ```swift Dollar.sequence(0..4) => [0, 1, 2, 3] Dollar.sequence(-2.0..2.0) => [-2.0, -1.0, 0.0, 1.0] Dollar.sequence((0..20).by(5)) => [0, 5, 10, 15] Dollar.sequence("abc") => ["a", "b", "c"] ``` ### remove - `Dollar.remove` Removes an element from array. ```swift Dollar.remove(["A", "B", "C", "D"], value: "B") => ["A", "C", "D"] ``` ### remove - `Dollar.remove` Removes all elements from an array that the `callback` returns true. ```swift let result = Dollar.remove([1, 2, 3, 4, 5, 6]) { $0 == 2 || $0 == 3 } result => [1, 4, 5, 6] ``` ### shuffle - `Dollar.shuffle` Shuffles and returns the new shuffled array ```swift let result = Dollar.shuffle([1, 2, 3, 4, 5, 6]) result => [4, 1, 3, 5, 6, 2] ``` ### size - `Dollar.size` Returns size of the array ```swift Dollar.size(["a", "b", "c") => 3 ``` ### sortedIndex - `Dollar.sortedIndex` Gives the smallest index at which a value should be inserted into a given the array is sorted. ```swift Dollar.sortedIndex([3, 4, 6, 10], value: 5) => 2 Dollar.sortedIndex([10, 20, 30, 50], value: 40) => 3 ``` ### transpose - `Dollar.transpose` Creates a tranposed matrix. ```swift Dollar.transpose([[1, 2, 3], [4, 5, 6]]) => [[1, 4], [2, 5], [3, 6]] ``` ### union - `Dollar.union` Creates an array of unique values, in order, of the provided arrays. ```swift Dollar.union([1, 2, 3], [5, 2, 1, 4], [2, 1]) => [1, 2, 3, 5, 4] ``` ### merge - `Dollar.merge` Creates an array of all values, including duplicates, of the arrays in the order they are provided. ```swift let arr = [1, 5] let arr2 = [2, 4] let arr3 = [5, 6] let result = Dollar.merge(arr, arr2, arr3) result => [1, 5, 2, 4, 5, 6] ``` ### uniq - `Dollar.uniq` Creates a duplicate-value-free version of an array. ```swift Dollar.uniq([1, 2, 1, 3, 1]) => [1, 2, 3] Dollar.uniq([1, 2.5, 3, 1.5, 2, 3.5]) { floor($0) } => [1, 2.5, 3] ``` ### without - `Dollar.without` Creates an array excluding all provided values. ```swift Dollar.without([3, 4, 5, 3, 5], values: 3, 5) => [4] Dollar.without([3, 4, 5, 3, 5], values: 4) => [3, 5, 3, 5] Dollar.without([3, 4, 5, 3, 5], values: 3, 4, 5) => [] ``` ### xor - `Dollar.xor` Creates an array that is the symmetric difference of the provided arrays. ```swift Dollar.xor([1, 2, 3], [5, 2, 1, 4]) => [3, 4, 5] ``` ### zip - `Dollar.zip` Creates an array of grouped elements, the first of which contains the first elements of the given arrays. ```swift Dollar.zip(["fred", "barney"], [30, 40], [true, false]) as [NSObject] => [["fred", 30, true], ["barney", 40, false]] ``` ### zipObject - `Dollar.zipObject` Creates an object composed from arrays of keys and values. ```swift Dollar.zipObject(["fred", "barney"], values: [30, 40]) => ["fred": 30, "barney": 40] ``` ### partition - `Dollar.partition` Produces an array of arrays, each containing n elements, each offset by step. Stops after a partition is less than n length. ```swift let arr = [1, 2, 3, 4, 5] Dollar.partition(arr, n: 2) => [[1, 2], [3, 4]] Dollar.partition(arr, n: 4, step: 1) => [[1, 2, 3, 4], [2, 3, 4, 5]] Dollar.partition(arr, n: 4, step: 1, pad: nil) => [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5]] Dollar.partition(arr, n: 4, step: 1, pad: [6, 7, 8]) => [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]] ``` ### partitionAll - `Dollar.partitionAll` Produces an array of arrays, each containing n elements, each offset by step. Continues after a partition is less than n length. ```swift Dollar.partitionAll([1, 2, 3, 4, 5], n:4, step: 1) => [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5], [4, 5], [5]] ``` ### partitionBy - `Dollar.partitionBy` Applies a function to each element in array, splitting it each time the function returns a new value. ```swift Dollar.partitionBy([1, 2, 3, 4, 5]) { $0 % 2 == 0 } => [[1], [2, 4], [3, 5], [6]] Dollar.partitionBy([1, 7, 3, 6, 10, 12]) { $0 % 3 } => [[1, 7], [3, 6], [10], [12]] ``` ## Dictionary ## ### keys - `Dollar.keys` Creates an array of keys given a dictionary. ```swift Dollar.keys(["Dog": 1, "Cat": 2]) => ["Dog", "Cat"] ``` ### values - `Dollar.values` Creates an array of values given a dictionary ```swift Dollar.values(["Dog": 1, "Cat": 2]) => [1, 2] ``` ### merge - `Dollar.merge` Merges all of the dictionaries together and the latter dictionary overrides the value at a given key ```swift let dict: Dictionary = ["Dog": 1, "Cat": 2] let dict2: Dictionary = ["Cow": 3] let dict3: Dictionary = ["Sheep": 4] Dollar.merge(dict, dict2, dict3) => ["Dog": 1, "Cat": 2, "Cow": 3, "Sheep": 4] ``` ### pick - `Dollar.pick` Creates a shallow clone of a dictionary composed of the specified keys. ```swift Dollar.pick(["Dog": 1, "Cat": 2, "Cow": 3], keys: "Dog", "Cow") => ["Dog": 1, "Cow": 3] ``` ### omit - `Dollar.omit` Creates a shallow clone of a dictionary excluding the specified keys. ```swift Dollar.omit(["Dog": 1, "Cat": 2, "Cow": 3, "Sheep": 4], keys: "Cat", "Dog") => ["Cow": 3, "Sheep": 4] ``` ## Object ## ### tap - `Dollar.tap` Invokes interceptor with the object and then returns object. ```swift var beatle = Car(name: "Fusca") Dollar.tap(beatle, {$0.name = "Beatle"}).color = "Blue" ``` ## Function ## ### after - `Dollar.after` Creates a function that executes passed function only after being called n times. ```swift var saves = ["profile", "settings"]; let asyncSave = { (function: () -> ()?) in function() // Saving right away for testing // but in real world would be async } var isDone = false var completeCallback = Dollar.after(saves.count) { isDone = true } for elem in saves { asyncSave(completeCallback) } isDone => true ``` ### bind - `Dollar.bind` Crea ... ...

近期下载者

相关文件


收藏者