You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
415 B

  1. //
  2. // Promise+First.swift
  3. // then
  4. //
  5. // Created by Sacha DSO on 31/01/2018.
  6. // Copyright © 2018 s4cha. All rights reserved.
  7. //
  8. import Foundation
  9. extension Promise {
  10. public func first<E>() -> Promise<E> where T == [E] {
  11. return self.then { unwrap($0.first) }
  12. }
  13. }
  14. extension Promise {
  15. public func last<E>() -> Promise<E> where T == [E] {
  16. return self.then { unwrap($0.last) }
  17. }
  18. }