Merge pull request #4 from 0xLeif/develop

1.1.0
This commit is contained in:
Zach Eriksen 2021-06-24 19:58:28 -05:00 committed by GitHub
commit b2ad6e88ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 37 additions and 0 deletions

View File

@ -230,3 +230,40 @@ private extension Object {
return unwrappedValue
}
}
extension Object: CustomStringConvertible {
public var description: String {
"""
Object {
\(
variables
.map { (key, value) in
guard let object = value as? Object else {
return "|\t* \(key): \(value) (\(type(of: value)))"
}
let values = object.description.split(separator: "\n")
.dropFirst()
if values.dropLast().isEmpty {
return "|\t* \(key): Object { }"
}
return "|\t* \(key): Object {\n\(values.map { "|\t \($0)" }.joined(separator: "\n"))"
}
.joined(separator: "\n")
)
}
"""
}
}
extension Object: Hashable {
public static func == (lhs: Object, rhs: Object) -> Bool {
lhs.description == rhs.description
}
public func hash(into hasher: inout Hasher) {
hasher.combine(description)
}
}