mirror of
https://github.com/mas-cli/mas
synced 2024-11-26 21:40:19 +00:00
e6e2ccab0d
swiftformat Sources Tests
27 lines
654 B
Swift
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()
|
|
}
|
|
}
|
|
}
|