mas/Sources/MasKit/Network/URLSession+NetworkSession.swift
Ross Goldberg e6e2ccab0d Updated swift source by running:
swiftformat Sources Tests
2024-02-05 16:03:51 -05:00

27 lines
654 B
Swift

//
// URLSession+NetworkSession.swift
// MasKit
//
// Created by Ben Chatelain on 1/5/19.
// Copyright © 2019 mas-cli. All rights reserved.
//
import Foundation
import PromiseKit
extension URLSession: NetworkSession {
public func loadData(from url: URL) -> Promise<Data> {
Promise { seal in
dataTask(with: url) { data, _, error in
if let data {
seal.fulfill(data)
} else if let error {
seal.reject(error)
} else {
seal.reject(MASError.noData)
}
}
.resume()
}
}
}