<commit_before>
# Extensions

## Swift

#### String

```swift
"Hello!".length                 -> 6
"Hello!"[0]                     -> "H"
"Hello!"[0 ..< 3]               -> "Hel"

"     Hello!     ".trimmed()    -> "Hello!"
"Hello!".truncated(3)           -> "Hel"
"Hello World!".words            -> ["Hello", "World"]

"<EMAIL>".isValidEmail   -> true
"allan.com".isValidEmail        -> false

"My Name&urlInjection=true".urlEncoded() -> "My%20Name%26urlInjection%3Dtrue"
```

#### Array

```swift
[1, 2, 3].get(0)  -> Optional(1)
[1, 2, 3].get(42) -> nil

var a = ["Hello", "World", "123"]
a.remove("123")
a -> ["Hello", "World"]

// Map + remove nil values. Doesn't flatten if multiple level of array like flatMap does
["Hello", "World", nil, "Sup?", nil].optionalMap { $0?.uppercased() } -> ["HELLO", "WORLD", "SUP?"]
```

## UIKit

#### UIView

AutoLayout Helpers

```swift
let subview = UIView()

subview.autoAttach(to: superview) {
    $0.autoPin(.centerX)
    $0.autoPin(.top, constant: 25)
    $0.autoPin([.width, .height], toItem: nil, constant: 50)
}

==

superview.addConstraints([
    NSLayoutConstraint(item: subview, attribute: .centerX, relatedBy: .equal, toItem: superview, attribute: .centerX, multiplier: 1, constant: 0),
    NSLayoutConstraint(item: subview, attribute: .top, relatedBy: .equal, toItem: superview, attribute: .top, multiplier: 1, constant: 25),
    NSLayoutConstraint(item: subview, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50),
    NSLayoutConstraint(item: subview, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50)
])
```

[More Info](UIKit/UIView/UIViewAutoLayoutExtensions.swift)
<commit_msg>Fix: README<commit_after>
# Extensions

## Swift

#### String

```swift
"Hello!".length                 -> 6
"Hello!"[0]                     -> "H"
"Hello!"[0 ..< 3]               -> "Hel"

"     Hello!     ".trimmed()    -> "Hello!"
"Hello!".truncated(3)           -> "Hel"
"Hello World!".words            -> ["Hello", "World"]

"<EMAIL>".isValidEmail   -> true
"allan.com".isValidEmail        -> false

"My Name&urlInjection=true".urlEncoded() -> "My%20Name%26urlInjection%3Dtrue"
```

#### Array

```swift
[1, 2, 3].get(0)  -> Optional(1)
[1, 2, 3].get(42) -> nil

var a = ["Hello", "World", "123"]
a.remove("123")
a -> ["Hello", "World"]

// Map + remove nil values. Doesn't flatten if multiple level of array like flatMap does
["Hello", "World", nil, "Sup?", nil].optionalMap { $0?.uppercased() } -> ["HELLO", "WORLD", "SUP?"]
```

## UIKit

#### UIView

AutoLayout Helpers

```swift
let myView = UIView()

myView.autoAttach(to: superview) {
    $0.autoPin(.centerX)
    $0.autoPin(.top, constant: 25)
    $0.autoPin([.width, .height], toItem: nil, constant: 50)
}

==

let myView = UIView()

myView.translatesAutoresizingMaskIntoConstraints = false
superview.addSubview(myView)
superview.addConstraints([
    NSLayoutConstraint(item: myView, attribute: .centerX, relatedBy: .equal, toItem: superview, attribute: .centerX, multiplier: 1, constant: 0),
    NSLayoutConstraint(item: myView, attribute: .top, relatedBy: .equal, toItem: superview, attribute: .top, multiplier: 1, constant: 25),
    NSLayoutConstraint(item: myView, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50),
    NSLayoutConstraint(item: myView, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 50)
])
```

[More Info](UIKit/UIView/UIViewAutoLayoutExtensions.swift)

{'fraction_non_alphanumeric': 0.18703241895261846, 'fraction_numerical': 0.02493765586034913, 'mean_word_length': 3.718954248366013, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3733118', 'n_tokens_mistral': 1328, 'n_tokens_neox': 1233, 'n_words': 305}